Export to Text

For work, I wrote this crappy little Python script that extracts individual email messages from the standard “.mbox” format used by Not all that impressive, but marginally useful.

It’s pretty restrictive as to its operation; everything must be in the right place for it to work properly. It doesn’t handle attachments yet, so you’ll get ugly ASCII shit at the tail end of your exported emails. The cStringIO module will probably work for attachments, I just haven’t figured out how to do it, yet. has a really good “Save as…” function, where the body of the email is saved as an RTF, and attachments are linked directly from the RTF in their native format. Only seems to work that way on 10.2.4, though (so far).

But if you want to do a mass export of multiple email messages, this little script may come in handy… especially if you get sick of “File > Save as…” by the 6th email.

Here’s the code. Download and tweak at will. No copyright, no worries. changed the format it uses to store mail messages, thus invalidating this script; let me know if you want it anyway.

Oops. One thing I forgot in the documentation: run it from the command line ( after making it executable (chmod +x).

Posted in Mac