Visual Basic 6.0 Requires Chilkat v11.0.0+
Visual Basic 6.0
Preview POP3 messages and download a complete email
See more Email Object Examples
Read a short preview for each of up to five messages into an EmailBundle, print their subjects, and download the complete first entry into a separate Email. Configure a POP3 account that supports UIDL and TOP. All messages stay on the server.
Chilkat Visual Basic 6.0 Downloads
Dim success As Long
success = 0
' Assumes Chilkat is unlocked. See Global Unlock Sample.
Dim mail As New ChilkatMailMan
mail.MailHost = "pop.example.com"
mail.MailPort = 995
mail.PopSsl = 1
mail.RequireSslCertVerify = 1
mail.PopUsername = "MAIL_USER"
mail.PopPassword = "MAIL_PASSWORD"
Dim previews As New ChilkatEmailBundle
' Keep the messages and request minimal previews. Range indexes are zero-based and inclusive.
success = mail.FetchRange(1,1,0,0,4,previews)
If (success <> 1) Then
Debug.Print mail.LastErrorText
Exit Sub
End If
If (previews.MessageCount = 0) Then
Debug.Print "There are no messages to preview."
success = mail.Pop3EndSession()
If (success <> 1) Then
Debug.Print mail.LastErrorText
Exit Sub
End If
Exit Sub
End If
Dim header As New ChilkatEmail
Dim i As Long
i = 0
Do While (i < previews.MessageCount)
success = previews.EmailAt(i,header)
If (success <> 1) Then
Debug.Print previews.LastErrorText
Exit Sub
End If
Debug.Print header.Uidl & " " & header.Subject
i = i + 1
Loop
' A UI could use its selected row here. FetchFull uses the preview's POP3 identity.
success = previews.EmailAt(0,header)
If (success <> 1) Then
Debug.Print previews.LastErrorText
Exit Sub
End If
Dim email As New ChilkatEmail
success = mail.FetchFull(header,email)
If (success <> 1) Then
Debug.Print mail.LastErrorText
Exit Sub
End If
success = mail.Pop3EndSession()
If (success <> 1) Then
Debug.Print mail.LastErrorText
Exit Sub
End If
Debug.Print "Full message: " & email.Subject & " Files: " & email.NumAttachments
success = email.SaveEml("pop-received.eml")
If (success <> 1) Then
Debug.Print email.LastErrorText
Exit Sub
End If
Debug.Print "Saved pop-received.eml."