PureBasic
PureBasic
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 PureBasic Downloads
IncludeFile "CkEmailBundle.pb"
IncludeFile "CkEmail.pb"
IncludeFile "CkMailMan.pb"
Procedure ChilkatExample()
success.i = 0
; 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.
mailman.i = CkMailMan::ckCreate()
If mailman.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
; Load emails from a local .mbx mailbox file (no server connection is made).
bundle.i = CkEmailBundle::ckCreate()
If bundle.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success = CkMailMan::ckLoadMbxFile(mailman,"qa_data/mbx/inbox.mbx",bundle)
If success = 0
Debug CkMailMan::ckLastErrorText(mailman)
CkMailMan::ckDispose(mailman)
CkEmailBundle::ckDispose(bundle)
ProcedureReturn
EndIf
n.i = CkEmailBundle::ckMessageCount(bundle)
Debug "Loaded " + Str(n) + " emails from the .mbx file."
email.i = CkEmail::ckCreate()
If email.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
i.i
For i = 0 To n - 1
success = CkEmailBundle::ckEmailAt(bundle,i,email)
Debug CkEmail::ckSubject(email)
Next
; Note: The path "qa_data/mbx/inbox.mbx" is a relative local filesystem path,
; relative to the current working directory of the running application.
CkMailMan::ckDispose(mailman)
CkEmailBundle::ckDispose(bundle)
CkEmail::ckDispose(email)
ProcedureReturn
EndProcedure