PowerBuilder
PowerBuilder
Download the Full Version of a Partial Email
See more POP3 Examples
Demonstrates the Chilkat MailMan.FetchFull method, which downloads the complete version of a header-only or partial Email and stores it in a second Email. The full result includes the complete body and any attachments, and the partial email must retain its UIDL. This example previews message 1 (headers only) and then downloads it in full.
Background: A common pattern is to download headers first — cheap and fast — show the user a message list, and only pull the full content when a message is actually opened.
FetchFull completes that "download on demand" flow: given a partial email (which carries its UIDL), it fetches the rest from the server. This keeps bandwidth and latency low when browsing a large mailbox.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Mailman
oleobject loo_PartialEmail
oleobject loo_FullEmail
li_Success = 0
// Demonstrates the MailMan.FetchFull method, which downloads the complete version of a
// header-only or partial Email and stores it in a second Email. The full result includes
// the complete body and any attachments. The partial email must retain its UIDL.
loo_Mailman = create oleobject
li_rc = loo_Mailman.ConnectToNewObject("Chilkat.MailMan")
if li_rc < 0 then
destroy loo_Mailman
MessageBox("Error","Connecting to COM object failed")
return
end if
// Configure the POP3 server connection.
loo_Mailman.MailHost = "pop.example.com"
loo_Mailman.MailPort = 995
loo_Mailman.PopSsl = 1
loo_Mailman.PopUsername = "user@example.com"
loo_Mailman.PopPassword = "myPassword"
// First fetch message 1 as headers only (a fast preview). headerOnly=1.
loo_PartialEmail = create oleobject
li_rc = loo_PartialEmail.ConnectToNewObject("Chilkat.Email")
li_Success = loo_Mailman.FetchOne(1,0,1,loo_PartialEmail)
if li_Success = 0 then
Write-Debug loo_Mailman.LastErrorText
destroy loo_Mailman
destroy loo_PartialEmail
return
end if
Write-Debug "Preview subject: " + loo_PartialEmail.Subject
// Now download the complete message (body and attachments).
loo_FullEmail = create oleobject
li_rc = loo_FullEmail.ConnectToNewObject("Chilkat.Email")
li_Success = loo_Mailman.FetchFull(loo_PartialEmail,loo_FullEmail)
if li_Success = 0 then
Write-Debug loo_Mailman.LastErrorText
destroy loo_Mailman
destroy loo_PartialEmail
destroy loo_FullEmail
return
end if
Write-Debug "Full email NumAttachments: " + string(loo_FullEmail.NumAttachments)
// Note: Explicitly connecting/authenticating is optional. Chilkat MailMan automatically
// connects and authenticates -- using the property settings above -- whenever a server
// operation requires it. Calling the explicit connect/authenticate methods can still be
// helpful to determine whether a failure occurs while connecting or while authenticating.
destroy loo_Mailman
destroy loo_PartialEmail
destroy loo_FullEmail