1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| Using client As New Pop3Client()
' Connect to the server
Try
client.Connect("pop.mail.yahoo.com", "995", True)
' Authenticate ourselves towards the server
client.Authenticate(login_nom, login_psw)
If client.Connected = True Then
' Get the number of messages in the inbox
Dim messageCount As Integer = client.GetMessageCount()
nbremailonline = messageCount
'télécharge les x derniers messages
If messageCount > xderniermessage Then
debutcpt = (messageCount - xderniermessage)
Else
debutcpt = 1
End If
' We want to download all messages
Dim allMessages As New List(Of Message)(messageCount)
' Messages are numbered in the interval: [1, messageCount]
' Ergo: message numbers are 1-based.
For i As Integer = messageCount To debutcpt Step -1
allMessages.Add(client.GetMessage(i))
' Me.Text = "telechargement des messages .... " & (messageCount - i) & "/" & (messageCount - debutcpt)
Next
' Now return the fetched messages
lstmsg = allMessages
End If
Catch
End Try
End Using |