Well,
what you do yourself is mostly ... and so i could find some bits & peaces...
for those who might be interested: here's the result & it works! ->gvMail is a gridvieuw ;):
<pre lang="vb">
Imports OpenPop.Pop3
Imports OpenPop.Mime
Imports System.io
Public Class Form1
Dim SSL As Boolean
Dim PopHost As String
Dim UserName As String
Dim WW As String
Dim PortNm As Integer
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
PopHost = "pop.gmail.com"
PortNm = 995
WW = "password"
UserName = someone@gmail.com
TxtHostname.Text = PopHost
CboAccount.Text = UserName
TxtPort.Text = PortNm
End Sub
Private Sub CmdGetM_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdGetM.Click
If ChbSSL.Checked = True Then
SSL = True
Else
SSL = False
End If
Me.Read_Emails()
End Sub
Private Sub Read_Emails()
Me.Cursor = Cursors.WaitCursor
Dim pop3Client As Pop3Client
pop3Client = New Pop3Client()
pop3Client.Connect(PopHost, Val(PortNm), SSL)
If pop3Client.Connected = False Then
TxtCounter.BackColor = Color.Red
Else
TxtCounter.BackColor = Color.LightGreen
pop3Client.Authenticate(UserName, WW, AuthenticationMethod.UsernameAndPassword)
If ChbReset.Checked = True Then pop3Client.Reset()
Dim count As Integer = pop3Client.GetMessageCount()
TxtCounter.Text = count
TxtCounter.Update()
Dim Email(7) As String, GvIndex As Integer = -1, message As Message
For i As Integer = count To 1 Step -1
TxtCounter.Text = GvIndex + 2 & "/" & count
TxtCounter.Update()
message = pop3Client.GetMessage(i)
Email(1) = i 'MessageNumber
Email(2) = message.Headers.Subject.ToString
Email(3) = message.Headers.DateSent.ToString
Email(4) = message.Headers.From.DisplayName.ToString & "(" & message.Headers.From.Address.ToString & ")"
Email(5) = ""
If message.Headers.To.Count > 0 Then
Email(5) = Email(5) & "TO:" & vbCrLf
For Each tomailaddress As OpenPop.Mime.Header.RfcMailAddress In message.Headers.To
Email(5) = Email(5) & tomailaddress.Address & vbCrLf
Next
End If
If message.Headers.Cc.Count > 0 Then
Email(5) = Email(5) & "CC:" & vbCrLf
For Each ccmailaddress As OpenPop.Mime.Header.RfcMailAddress In message.Headers.Cc
Email(5) = Email(5) & ccmailaddress.Address & vbCrLf
Next
End If
If message.Headers.Bcc.Count > 0 Then
Email(5) = Email(5) & "BCC:" & vbCrLf
For Each bccmailaddress As OpenPop.Mime.Header.RfcMailAddress In message.Headers.Bcc
Email(5) = Email(5) & bccmailaddress.Address & vbCrLf
Next
End If
Dim body As MessagePart = message.FindFirstHtmlVersion()
If body IsNot Nothing Then
Email(6) = body.GetBodyAsText()
Else
body = message.FindFirstPlainTextVersion()
If body IsNot Nothing Then
Email(6) = body.GetBodyAsText()
End If
End If
Dim attachments As List(Of MessagePart) = message.FindAllAttachments()
Email(7) = ""
For Each attachment As MessagePart In attachments
If Email(7) = "" Then
Email(7) = Email(7) & attachment.FileName
Else
Email(7) = Email(7) & vbCrLf & attachment.FileName
End If
'Dim ContentID As String = attachment.ContentId 'If this is set then the attachment is inline.
'Dim ContentType As String = attachment.ContentType.MediaType 'type of attachment pdf, jpg, png, etc.
File.WriteAllBytes(TxtAttDest.Text & attachment.FileName.ToString, attachment.Body) '//overwrites MessagePart.Body with attachment
Next
gvEmails.Rows.Add()
GvIndex = GvIndex + 1
gvEmails.Item(0, GvIndex).Value = Email(1)
gvEmails.Item(1, GvIndex).Value = Email(2)
gvEmails.Item(2, GvIndex).Value = Email(3)
gvEmails.Item(3, GvIndex).Value = Email(4)
gvEmails.Item(4, GvIndex).Value = Email(5)
gvEmails.Item(5, GvIndex).Value = Email(6)
gvEmails.Item(6, GvIndex).Value = Email(7)
Next
pop3Client.Disconnect()
End If
Me.Cursor = Cursors.Default
End Sub
End Class