2014-07-11 4 views
0

을 사용하여 제목 내용을 텍스트 파일로 저장 메일을 텍스트 파일로 저장에서 vb.net 사이의 문제가 발생했습니다. 난 내 작업에 따라 다음과 같은 코드를했던 : -받은 편지함의 첫 번째 메일 읽기, pop3client

public sub rearmail() 
Dim pop3Client As Pop3Client 
      If (Session("Pop3Client") Is Nothing) Then 
       pop3Client = New Pop3Client 
       pop3Client.Connect("pop.gmail.com", 995, True) 
       pop3Client.Authenticate("[email protected]", "password") 
       Session("Pop3Client") = pop3Client 
      Else 
       pop3Client = CType(Session("Pop3Client"), Pop3Client) 
      End If 'connect to the inbox with username and pass word authentication 
     Dim message As Message = pop3Client.GetMessage(0) 
     dim frm as string ' to store from address 
     dim subj as string ' to store the subject 
     dim mdate as date ' to store the date and time 
     frm=message.Headers.From.Address 
     subj= message.Headers.Subject 
     mdate=message.Headers.DateSent 
    '**** no i need to read the mail message and save it as a notepad file **** 
    end sub 

은 내가 사용하는 메일 읽기를 많이 시도했다 : - 다음과 같이

Dim message As Message = pop3Client.GetMessage(0) 

을 : -

Dim str As MailMessageEventArgs 
dim strmsg as string 
strmsg=str..Message.Body.ToString 'error null error exception at run time 
strmsg=message.MessagePart.Body ' nothing will return 

같은 현명한 메시지 개체를 많이하지만 목표를 달성하지 못하면이 커뮤니티의 전문가가 문제를 극복하는 데 도움이되기를 바랍니다. 미리 감사드립니다 ..... ♥

답변

0

문제를 해결해 주신 분께 감사드립니다. 해결책을 얻었으니 지금 알려 드리겠습니다. 다음은 메일 본문 내용을 읽는 코드 세그먼트입니다. -

Dim messagePart As MessagePart = message.MessagePart.MessageParts(0) 
MsgBox(messagePart.BodyEncoding.GetString(messagePart.Body))