Using ionosPop As New Pop3Mail.Pop3(strLicenseKey)
With ionosPop
Try
.Connect(strPopHpst, strPopPort)
Catch ex As Exception
Debug.Print("Error connecting: " & ex.Message)
Return
End Try
Try
.Login(strEmailId, strPassword)
Catch ex As Exception
Debug.Print("Error in login: " & ex.Message)
Return
End Try
Dim inboxMessages As Integer = .InboxMessageCount
Debug.Print("Inbox Message Count: " & inboxMessages.ToString & Environment.NewLine)
If inboxMessages > 0 Then
Dim msgCollection As MailMessageCollection
Try
msgCollection = .DownloadEntireMessages(1, inboxMessages)
Catch ex As Exception
Debug.Print("Error in DownloadEntireMessages: " & ex.Message)
Return
End Try
For i As Integer = 0 To msgCollection.Count - 1
Using msg As MailMessage = msgCollection(i)
Debug.Print("From: " & msg.From.AsString)
Debug.Print("To: " & msg.To.AsString)
Debug.Print("Subject: " & msg.Subject)
Debug.Print("Body: " & msg.BodyPlainText)
Try
If .DeleteMessage(i + 1) Then
Debug.Print($"Marked message #{i + 1} for deletion.")
End If
Catch ex As Exception
Debug.Print("Error in DeleteMessage" & ex.Message)
End Try
Debug.Print(Environment.NewLine)
End Using
Next
Else
Debug.Print("No messages were found in \Inbox")
End If
If .Disconnect() Then
If inboxMessages <> 0 Then
Debug.Print("Successfully deleted messages.")
End If
Debug.Print("Connection succesfully closed.")
Else
Debug.Print("Failed to delete messages.")
Debug.Print("Error closing connection.")
End If
End With
End Using
Comments
0 B
|👍
/👎
0 B
|👍
/👎
0 B
|👍
/👎
0 B
|👍
/👎
0 B
|👍
/👎
0 B
|👍
/👎
0 B
|👍
/👎
0 B
|👍
/👎
0 B
|0 👍
/0 👎
0 B
|👍
/👎