How to Create Email Templates in Automator

by Colter Reed
2:07 read (647 words)
by Colter Reed
2:07 read (647 words)

We are constantly sending emails (over 100 billion every day by some estimates). We regularly distribute information via email, and can send the same basic message monthly, weekly, or daily with little variation. As long as the email has to be sent, it’s a great candidate for automating.

I recently helped my wife send a weekly email more efficiently. Each week, she sends out the list of hymns we’ll be singing for the next few Sundays. She had a good process in place, but she was always worried that she was going to forget to add the BCC recipients (and it’s not easy to check afterwards). I helped her automate her process a little so she would have one less thing to worry about.

There are multiple ways you can automate creating an email draft and each has its own strengths and weaknesses. Since she uses the built-in Mail.app and wants something that would be easy for her to maintain, we created an Automator application.

Here’s how to create an Automator action that you can double-click to create a draft message in Mail.app. If you drop files on it, they will be attached to the message.

Creating the Application

To create an email template in Automator:

  1. Launch Automator and create a new document.
  2. Choose Application for the type of workflow.
  3. From the Library, select Mail > New Mail Message and drag it into the workflow.
  4. Fill out the message template. We’re not going to add a Send Outgoing Messages step, so what you put in the template isn’t final; it’s just a starting point for the message. You can edit the message before you send it.
An automator workflow to create a new email message.

An automator workflow to create a new email message.

Click Run to try it out. Mail will launch and bring up a new message draft that’s already filled out. Instead of starting from scratch each time, you can just tweak the message and go!

An email draft created for us by Automator.

An email draft created for us by Automator.

Putting the Date in the Subject Line

The workflow would work like it is, but let’s take it one step futher by putting the correct date in the subject line.

If your workflow just needs today’s date, you’re in luck: the Date & Time > Today’s Date variable lets you insert today’s date without the scripting. Since I want to use this Sunday’s date, I’m going to use Utilities > Shell Script, which lets you insert the output of any Unix command.

  1. Switch the Library from viewing Actions to Variables.
  2. Drag a Utilities > Shell Script variable token into the subject field.
  3. Edit the subject to accommodate the token.
  4. Right-click on the token and select Edit… to configure the script. You can use any script here that writes to stdout. I’m using the date command to get the date of the upcoming Sunday.
A little work up front can save lots of time down the road.

A little work up front can save lots of time down the road.

Try running your script again. The draft should be the same, except the subject line will have Sunday’s date on it. One less thing to worry about when you’re sending out the email.

The same email draft, but with the correct date automatically added for us!

The same email draft, but with the correct date automatically added for us!

Unfortunately, you can only use variables in the subject line. If you want to dynamically determine the recipients or message body, it will probably be easier to do the whole thing in AppleScript instead of Automator.

As with any time you automate your workflow, wait until the workflow is stabilized before you try to automate it. Otherwise, you’re either going to optimize for the wrong thing or automate work you don’t need to be doing anyway. The best way to reduce the time you spend on a task is elimination, not automation.

Also, be sure the time and energy you spend automating is time and energy you’ll save doing the task. It’s easy to get caught up in automation and optimization and pretty soon feature creep starts to take over. This chart from XKCD is a handy reference.

What tasks could you automate (or eliminate) to save yourself time and energy? What could you do with the time you save? Share your thoughts in the comments below!

Question: What tasks could you automate (or eliminate) to save yourself time and energy? What could you do with the time you save? Share your thoughts in the comments, on Twitter, LinkedIn, or Facebook.