Sample code for 30+ languages & platforms
Perl

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

Chilkat2 Perl
use strict;
use warnings;
use Chilkat2;

# 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.

my $mailman = Chilkat2::MailMan->new;

# Load emails from a local .mbx mailbox file (no server connection is made).
my $bundle = Chilkat2::EmailBundle->new;

my $success = $mailman->LoadMbxFile('qa_data/mbx/inbox.mbx', $bundle);
if (!$success) {
    print $mailman->LastErrorText, "\n";
    exit;
}

my $n = $bundle->MessageCount;
print 'Loaded ', $n, " emails from the .mbx file.\n";

my $email = Chilkat2::Email->new;
for my $i (0 .. $n - 1) {
    $success = $bundle->EmailAt($i, $email);
    print $email->Subject, "\n";
}

# Note: The path "qa_data/mbx/inbox.mbx" is a relative local filesystem path,
# relative to the current working directory of the running application.