#4 Extract each email messages to individual file


Basically what I am after is a tool that will iterate
through a PST file and save all the email messages into
separate files as rfc822 / mime format preserving all the
body parts headers and attachments. We need to
export the messages to be able to import them into a
document management system.


  • Tim Heaney

    Tim Heaney - 2004-01-09

    Logged In: YES

    Forgive me for speaking out of turn, I just stumbled in here
    looking for something to convert a .dbx file to mbox format,

    It seems to me you don't really need this. Once you have
    files in mbox format, you can use any number of methods to
    split them into individual messages. You can use formail
    (part of procmail), along with a little shell script


    # createfile - Use this with formail to split a Unix mbox into
    # individual files named message.1, message.2, ...
    # FILENO=1 formail -ds createfile < mboxfile
    # Basically, formail is looking for the name of a program,
    so this is
    # a program which simply redirects its input to a file.

    cat > message.$FILENO

    or Perl's Email::Folder module

    perl -MEmail::Folder -e
    F,"> message.$n" or die; print F $m->as_string}' mboxfile

    or Python's email and mailbox modules


    import email
    import mailbox

    num = 1
    for msg in mailbox.PortableUnixMailbox(open('mboxfile'),
    file = open('message.' + str(num), 'w')
    print >>file, msg
    num += 1

    or something similar in whatever your favorite scripting
    language is. Once you've got the data out of its proprietary
    format, the battle's already won.

  • Nobody/Anonymous

    Logged In: NO

    Se the manpage for csplit


    csplit mboxfilename "/^From /" {*}


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks