Dim pop3Server As String = ""
Dim pop3Port As Integer = "995"
Dim pop3UseSsl As Boolean = True
Dim username As String = ""
Dim password As String = ""
Using pop3 As New LumiSoft.Net.POP3.Client.POP3_Client()
pop3.Connect(pop3Server, pop3Port, pop3UseSsl)
pop3.Login(username, password )
Dim msgs As object = pop3.messages()
'获取某邮件信息
Dim messageBytes = msgs(4).MessageToByte '这是按第几封邮件查看邮件,有没有办法按主题内容,因为是按月份收取,发送是主题为【XX月报表】,这样就有1-12月,接收的时候可以月份来查看邮件下载附件。。。
Dim mime_message = LumiSoft.Net.Mail.Mail_Message.ParseFromByte(messageBytes)
Dim str As String = ""
str &= "发送人:" & mime_message.From(0).DisplayName & vbcrlf
str &= "发送地址:" & mime_message.From(0).Address & vbcrlf
str &= "主题:" & mime_message.Subject & vbcrlf
str &= "日期:" & mime_message.Date & vbcrlf
Dim fjs = mime_message.GetAttachments(False, False)
str &= "附件数:" & fjs.length & vbcrlf
str &= vbcrlf & vbcrlf & mime_message.BodyHtmlText
e.Form.Controls("TextBox1").Text = str
For Each entity As object In fjs
If entity.ContentType IsNot Nothing Then
Dim fileName As String = entity.ContentType.Param_Name
If Not String.IsNullOrEmpty(fileName) Then
Dim dir As New io.DirectoryInfo("D:\email\")
If Not dir.Exists Then
dir.Create()
End If
Dim path__1 As String = io.Path.Combine(dir.FullName, fileName)
Dim byteObj As object= entity.Body
Dim decodedDataStream As io.Stream = byteObj.GetDataStream()
Using fs As New io.FileStream(path__1, io.FileMode.Create)
LumiSoft.Net.Net_Utils.StreamCopy(decodedDataStream, fs, 4000)
End Using
msgbox(fileName & "已经被下载到" & path__1)
End If
End If
Next
End Using