A simple perl script, used in conjunction with find, can create an export file containing a tab-delimited list of the From, Subject, and Date fields of all emails in Mail. You could bring this into a spreadsheet or database for further processing. Modifying the script (the formail parameters, mainly) would allow you to extract the message body and other fields as well.

Read the rest of the article for the script and find syntax...

Create this script, name it (mailexport.pl was used in this exmaple), make it executable (chmod 755 mailexport.pl), and keep it in the directory from which you'll run the find command:

If you want to import the data into a Mac-ish program instead of UNIX-ish program, change the perl script to have "\\r" instead of "\\n". (Mac uses carriage return to delimit lines, UNIX uses line feed.)

Then, say you want to bring the data into Appleworks:

* In Appleworks, choose Open...
* Change the File Format popup to "All Available".
* Select the text file created by the script, but don't double-click or choose Open yet.
* Change Document Type popup to "Spreadsheet" or "Database", depending on which format you want to use.
* Hit Open and voila, it's imported!

You can accomplish the same thing, but it's easier to then modify mailbox2.pl to get the particular fields you want to have.

(Note that mailbox1.pl doesn't really do much. The only reason it exists is because formail reads stdin and I can't figure a way to pipe or redirect input to formail as a part of a find or xargs command. If there were a way to do it, all the work could be done in mailbox2.pl.)

When I previewed the routines, I had to double-up my backslashes for it to look right. But when it posted, they stayed doubled. Also, the backslash in front of greater-than and less-than need to go. Can the message be fixed by the admin?

Note that the $body = line reads only a single line of the body. You'd have to read all the rest of the lines and filter them to handle tabs and newlines somehow, if you intend to output to tab-delimited format. If you'll use DB routines to go straight to a database, that wouldn't be a problem.

This is a one-script version of wfolta's "Cleaner but two-script version"... plus I added the To: field, and made a few changes to grab all of the body text. Not that this script MUST be named mailexport.pl (unless you change it in the source code).

I noticed that if you drag a folder from the Entourage X Inbox to the Finder it saves it in a *.mbox format. So to make this work with Entourage, drag a folder from Entourage to the same Finder directory that the script is in (in this example the folder was called 'work' in Entourage, and in the Finder it appeared as 'work.mbox'). Next, use BBEdit (or ??) to change the line endings from Mac to Unix. Then in the Terminal from the directory that the script is in, type:

I have nothing else as delete messages for mac.com mailbox and outbox in Mailboxes, the input boxes are in separate folders together with drafts, deleted messages (again), message UIDs already downloaded, and sent messages.

I have tried the script with the name of one this folder instead of Mailboxes, but it does not seem to work.

These scripts should work with Jaguar. Note that the find command assumes the mailboxes are in Library, which I believe changed from early versions of Mail that had them in Mailboxes directly in your home directory. (At least I had a Mailboxes directory in my home directory, which I think was a result of that.)