AppleScript To Save Messages As PDFs With Specific Naming Convention
1: Prompts and allows the user to select one or more Apple Mail email messages from within Mail (10.4, 10.5, 10.6).
2: Prompts and allows the user to select a save-to folder.
3: For each message, saves it as a PDF file in the save-to folder, using the following naming convention for the PDF file:
"YYYY-MM-DD HH.MM.SS Email From FIRSTNAME LASTNAME - SUBJECT",
"YYYY-MM-DD HH.MM.SS Email To FIRSTNAME LASTNAME - SUBJECT",
where in the email date-sent stamp (if I am the sender) or date-received stamp (if I am the recipient):
YYYY = the year
MM = the two-digit month
DD = the two-digit day
HH = the two-digit hour (in 24-hour time)
MM = the two-digit minute
SS = the two-digit second
FIRSTNAME is the email sender's first name for email that I receive (or is the email recipient's first name for email that I send)
LASTNAME is the email sender's last name for email that I receive (or is the email recipient's first name for email that I send)
SUBJECT = the email's subject line
For example: 2010-04-10 16.32.48 Email From Kris Ryan - Status Of Payroll Updates.pdf
For example: 2010-04-10 16.33.55 Email To Sue Anderson - RE Status Of Payroll Updates.pdf (Colon omitted after "RE".)
4: For each attachment to the message, saves it as a PDF file in the same directory using the naming convention:
"YYYY-MM-DD HH.MM.SS Email From FIRSTNAME LASTNAME Z Attachment - NUMBER - FILENAME",
where:
YYYY-MM-DD HH.MM.SS Email From FIRSTNAME LASTNAME = as above
NUMBER = an integer representing the attachment number (1, 2, ...) sorted according to filename alphabetical order
FILENAME = the name of the file attached to the email, including its extension (.docx, .xlsx, etc.)
The letter "Z" sorts the attachment PDFs after its respective parent email in the directory.
For example: 2010-04-10 16.32.48 Email From Kris Ryan Z Attachment - 1 - List Of Suggestions To Moore.doc.pdf
For example: 2010-04-10 16.32.48 Email From Kris Ryan Z Attachment - 2 - Proposed Salary Adjustments.xls.pdf
For example: 2010-04-10 16.32.48 Email From Kris Ryan Z Attachment - 3 - Salary History.pps.pdf
Note: The email attachment may consist of a PDF or MS Office file (Word, Excel, Power Point); however, a smart implementation will be able to handle any attachment kind. If the attachment is a PDF file, then save it "as is" using the stipulated naming convention, without passing it through Distiller.
Thank you.
Kurt Todoroff
iMac 27-inch Quad-Core i7 2.93GHz, Mac OS X (10.6.4)