DataFlex
DataFlex
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 DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoMailman
Variant vPartialEmail
Handle hoPartialEmail
Variant vFullEmail
Handle hoFullEmail
String sTemp1
Integer iTemp1
Move False To iSuccess
// 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.
Get Create (RefClass(cComChilkatMailMan)) To hoMailman
If (Not(IsComObjectCreated(hoMailman))) Begin
Send CreateComObject of hoMailman
End
// Configure the POP3 server connection.
Set ComMailHost Of hoMailman To "pop.example.com"
Set ComMailPort Of hoMailman To 995
Set ComPopSsl Of hoMailman To True
Set ComPopUsername Of hoMailman To "user@example.com"
Set ComPopPassword Of hoMailman To "myPassword"
// First fetch message 1 as headers only (a fast preview). headerOnly=True.
Get Create (RefClass(cComChilkatEmail)) To hoPartialEmail
If (Not(IsComObjectCreated(hoPartialEmail))) Begin
Send CreateComObject of hoPartialEmail
End
Get pvComObject of hoPartialEmail to vPartialEmail
Get ComFetchOne Of hoMailman True 0 1 vPartialEmail To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoMailman To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComSubject Of hoPartialEmail To sTemp1
Showln "Preview subject: " sTemp1
// Now download the complete message (body and attachments).
Get Create (RefClass(cComChilkatEmail)) To hoFullEmail
If (Not(IsComObjectCreated(hoFullEmail))) Begin
Send CreateComObject of hoFullEmail
End
Get pvComObject of hoPartialEmail to vPartialEmail
Get pvComObject of hoFullEmail to vFullEmail
Get ComFetchFull Of hoMailman vPartialEmail vFullEmail To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoMailman To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComNumAttachments Of hoFullEmail To iTemp1
Showln "Full email NumAttachments: " iTemp1
// 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.
End_Procedure