could applescript be used to print mail messages in Mail.app into PDF automatically? The reason is cos I plan to save all mails within a mailbox to pdf and display on a website.
I’ve checked the dictionary for mail.app and it only appears to be able to print, but not to pdf.
Any work around for this? I’ve tried to find a eml 2 pdf converter but to no avail too…
The basic problem of print automation in Apple Mail is the absence of the «print without print dialog» command. Normally this command conveniently enables you to print documents using AppleScript without invoking the print dialog, but Apple Mail does not yet offer it.
Another problem is, that you cannot directly print Apple Mail’s message file format (*.emlx) from the Terminal, which would allow for an alternative automation approach (every eMail message has a unique ID that is also its file name).
Therefor my solution was to export all information available in an email message to another format (HTML/TXT) and then to print this new format into PDF using cups-pdf* and an application that allows for automatic printing (like Safari or TextEdit).
I invite you to study my humble results, maybe you can also make good use of them:
pergamail ¢ automatically print out incoming eMail messages and attachments previmail ¢ preview incoming eMail messages using Quick Look
The pergamail uses a TXT template, previmail uses a sexy looking HTML template
Please note, that you cannot easily control the output names of the generated PDF files when using cups-pdf. That might be a problem in your case.