Menu Close

Automatically Save Mail Attachments Using Automator and Keyboard Maestro

I have set up my firm’s case management system to email me three reports every Sunday evening. These reports arrive as attachments to email. For several months, I’ve been coming in on Monday morning and dragging those reports out of Mail and into Unclutter, which I keep in my Mac menu bar so I have easy access to certain files. I recently decided I would automate this process.

Looking around online, I found several AppleScripts purporting to accomplish this, but I wanted to see if I could accomplish this with Keyboard Maestro. I ended up doing it with Keyboard Maestro and Automator.

My Automator workflow, as depicted below, is pretty simple. It finds any email in my inbox that meets two conditions:

  1. The subject of the email must begin with words that are specific to the report emails; and
  2. The emails must have been sent in the last two days.

If those conditions are met, Automator gets the attachments from those messages and saves those attachments into the same Dropbox folder used by Unclutter to hold files. (I don’t know if I actually need the second step in the workflow).

Automator Mail Attachmentn Workflow

Then it was simply a matter of setting up a Keyboard Maestro macro that would launch the Automator workflow every Monday before I arrived at the office.

Keyboard Maestro trigger for Automator

The final step for me was to create a rule in Hazel to monitor Unclutter, and clean out old reports every week.

Hazel rule to clean out reports

Caveat: I just set up this system yesterday, and forced it to run out of its normal schedule. It worked fine. I’ll see this Sunday evening whether it runs on the schedule I designated.

Here are links to the Automator workflow and Keyboard Maestro macro:

Automator workflow

Keyboard Maestro macro