Sample code for 30+ languages & platforms
PowerBuilder

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 PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Mailman
oleobject loo_Bundle
integer n
oleobject loo_Email
integer i

li_Success = 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.

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

//  Load emails from a local .mbx mailbox file (no server connection is made).
loo_Bundle = create oleobject
li_rc = loo_Bundle.ConnectToNewObject("Chilkat.EmailBundle")

li_Success = loo_Mailman.LoadMbxFile("qa_data/mbx/inbox.mbx",loo_Bundle)
if li_Success = 0 then
    Write-Debug loo_Mailman.LastErrorText
    destroy loo_Mailman
    destroy loo_Bundle
    return
end if

n = loo_Bundle.MessageCount
Write-Debug "Loaded " + string(n) + " emails from the .mbx file."

loo_Email = create oleobject
li_rc = loo_Email.ConnectToNewObject("Chilkat.Email")

for i = 0 to n - 1
    li_Success = loo_Bundle.EmailAt(i,loo_Email)
    Write-Debug loo_Email.Subject
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.


destroy loo_Mailman
destroy loo_Bundle
destroy loo_Email