Mail.app rule to extract an email to a text file
On the Apple Discussion Boards, a poster called Cyclosaurus has provided an applescript
which when activated by a rule in Mail.app will save an email to a plain text file on the Desktop.
This could be very handy.
To use it, all you need to do is copy the text from his posting (above), paste it into Script Editor, compile it and save it off as a script in some memorable place (I find that ~/Library/Scripts/Applications/ Mail is memorable).
Then you need to hook it up to a Mail rule. Here I am using it to extract bibliographical records of books for importing into Bookends or EndNote, two reference managers for academic writing.
The rule recognises the subject line that the library adds to these emails, extracts the info to a plain text file on the Desktop called slash.txt, tags it with the MailTags
project for my work and dumps it into my mail archive. (A quick subject line search for “MARC record” will find them all again, so a rabbit warren of mailboxes is not required.)

The end result is a clean plain text file. The script appends any subsequently extracted emails to the end of the file:

This is unfortunately a hypothetical example. In real life I am not that organised or automated.
However, it gives you an idea of the applications to which the script could be put. Gathering a list of to-dos perhaps or saving a plain text copy of every email from your sweetheart. Or from a cyber-stalker. Or if set to “every message”, a full plain text archive of all the email you receive. Or to save a copy of every email that mentions Steve Jobs. Or whatever.
Tags: Apple Mail, Apple Mail Tips, applescript, email, extract, mail.app, plain text, Productivity, rulesRelated posts

December 14th, 2006 at 11:49 am
how could this be modified to avoid recording all that pesky metadata source text at the top of every email? I just want the subject of the emails in this case…