Apple Script to save email as PDF

I’ve done some Googling on this but all the articles I found are quite old.

I’d like to set up a Mail rule that saves specific emails as PDF’s and I thought Apple Script would be a good way to do this.

Does anyone know what script I could use to save a selected email (from the mail rule) as a PDF to my downloads folder? (I’ll then use Hazel to sort the PDF accordingly)

+1. I’ve been trying to do the same for a while.

The only way I could find was to use Email Archiver Pro.

Not exactly what you have asked for, but it does an awesome job of emails>PDF!

I think Macsparky has done this, but I can’t remember where - whether it was a blog, the paperless guide or Automators.

I remember setting it up on my desktop, but am away for several days so can’t help.

Perhaps someone else will recall?

…or, you can do it the easy way: Control+Option+Command + P.

1 Like

Mail.app does not have a scriptable interface for writing an email message to a PDF. The only way to do so is via the menu item (also accessible as noted with a keyboard shortcut).

You can AppleScript this by tell’ing System Events to control the user interface (you can get the same effect with the menu control actions in Keyboard Maestro).

Although I have done this, I have found it to be difficult to rely on in practice due to timing delays. Sometimes the save to PDF is fast; sometimes it will hang for a while. In addition, you need to do further UI scripting if you want to designate the file name for the saved email and its location, all of which add up to this being a rather inefficient and frustrating process.

What you are saying is that using AppleScript to manipulate the menus is hokey, and I agree. It would be better to use some intermediate program (as @Dougee implied), preferably a free one. I wasn’t able to identify a candidate.

This app looks really interesting and might do exactly what I need. Thanks!