Automate email body to PDFs and capture in DEVONThink

Hello automation gurus!

I have been looking to automate a seemingly simple task where I would like to capture emails from certain senders as PDF in my DEVONThink DB for future reference. It does not have to be DT, as long as I can a PDF file somewhere in my file system, I can then get Hazel to do all necessary file related steps.
Currently, I can achieve this manually via printing to PDF - however, this is a tedious manual process, and takes some time. I wonder if you are aware of any solution to this. Having searched on the forum I could not find a suitable solution.

So I would welcome your advice if this can be achieved with macOS tools - ideally, I would like this to be triggered automatically but I do not mind if I have to run the automation myself.
Any ideas?

Many thanks,

I haven’t tried it but if you use gmail/gsuite then you can use a script like this to save the email as a pdf in google drive and if you have google drive on mac you can make hazel watch that folder. I haven’t tried it myself but it seems like it should work.

You could easily tweak this solution a bit to do what you are seeking:

I’ve been building something similar in recent times.
It’s still a work in progress, but so far I am saving emails + their attachments to Dropbox using Integromat.
I then have Hazel convert the HTML body of the mail to PDF using “wkhtmltopdf”.

Here is the Integromat flow (the bottom half is the part that saves the HTML or TXT body):

And this is the shell script, that Hazel runs on the html file (after I have run some renaming automation):


wkhtmltopdf --encoding utf8 "$1" "${1%.*}.pdf"

This is, where I asked for help building it, here on the forum: Hazel HTML to PDF conversion

1 Like

Why don’t you just use Mail’s “Export as PDF …” in the Files menu? You could assign a shortcut to the entry in System Preferences.