Tcl
Tcl
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 Tcl Downloads
load ./chilkat.dll
set 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.
set mailman [new_CkMailMan]
# Load emails from a local .mbx mailbox file (no server connection is made).
set bundle [new_CkEmailBundle]
set success [CkMailMan_LoadMbxFile $mailman "qa_data/mbx/inbox.mbx" $bundle]
if {$success == 0} then {
puts [CkMailMan_lastErrorText $mailman]
delete_CkMailMan $mailman
delete_CkEmailBundle $bundle
exit
}
set n [CkEmailBundle_get_MessageCount $bundle]
puts "Loaded $n emails from the .mbx file."
set email [new_CkEmail]
for {set i 0} {$i <= [expr $n - 1]} {incr i} {
set success [CkEmailBundle_EmailAt $bundle $i $email]
puts [CkEmail_subject $email]
}
# Note: The path "qa_data/mbx/inbox.mbx" is a relative local filesystem path,
# relative to the current working directory of the running application.
delete_CkMailMan $mailman
delete_CkEmailBundle $bundle
delete_CkEmail $email