DataFlex
DataFlex
Load Emails from a .mbx Mailbox File
See more POP3 Examples
Demonstrates the Chilkat MailMan.LoadMbxFile method, which loads emails from a .mbx mailbox file and stores them in an EmailBundle. If a filter has been configured, only the matching emails are returned. This example loads a local mailbox file and iterates the resulting bundle.
Background: An
.mbx file is a single-file mailbox format that stores many messages concatenated together — historically produced by Outlook Express and similar clients. LoadMbxFile parses that archive into individual Email objects, which is useful for importing, migrating, or analyzing old mail without any server connection. No POP3 or SMTP session is involved — this reads purely from disk.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoMailman
Variant vBundle
Handle hoBundle
Integer n
Variant vEmail
Handle hoEmail
Integer i
String sTemp1
Move False To iSuccess
// Demonstrates the MailMan.LoadMbxFile method, which loads emails from a .mbx mailbox file
// and stores them in an EmailBundle. If a filter has been configured, only the matching
// emails are returned.
Get Create (RefClass(cComChilkatMailMan)) To hoMailman
If (Not(IsComObjectCreated(hoMailman))) Begin
Send CreateComObject of hoMailman
End
// Load emails from a local .mbx mailbox file (no server connection is made).
Get Create (RefClass(cComChilkatEmailBundle)) To hoBundle
If (Not(IsComObjectCreated(hoBundle))) Begin
Send CreateComObject of hoBundle
End
Get pvComObject of hoBundle to vBundle
Get ComLoadMbxFile Of hoMailman "qa_data/mbx/inbox.mbx" vBundle To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoMailman To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComMessageCount Of hoBundle To n
Showln "Loaded " n " emails from the .mbx file."
Get Create (RefClass(cComChilkatEmail)) To hoEmail
If (Not(IsComObjectCreated(hoEmail))) Begin
Send CreateComObject of hoEmail
End
For i From 0 To (n - 1)
Get pvComObject of hoEmail to vEmail
Get ComEmailAt Of hoBundle i vEmail To iSuccess
Get ComSubject Of hoEmail To sTemp1
Showln sTemp1
Loop
// Note: The path "qa_data/mbx/inbox.mbx" is a relative local filesystem path,
// relative to the current working directory of the running application.
End_Procedure