OS X Mail: Create HTML-formatted Auto-response With AppleScript and Rules

Do you respond to a lot of emails with the same or similar content?  You can use Apple’s Mail app to do this for you automatically with some AppleScript and email rules.  Hopefully, you already know about the privacy glitch associated with Apple’s Mail program and Spotlight and have disabled the indexing of your emails.  If not, do that now.  Then, follow the instructions below.

rule-created

Write The AppleScript (Or Download And Modify It)

To have an auto-response email sent whenever you receive a certain message, you will need to create an AppleScript like the one below:

Just modify the quoted HTML.  If your HTML has any double quotes in it, they will need to be escaped by putting a backslash in front of them.  If you don’t do this, your script will error out.

Save the AppleScript in

/Users/<your user>/Library/Application Scripts/com.apple.mail/

This will make it available within the Mail app.

Attach The AppleScript To A Mail Filter

It will now be available from within the Apple Mail rules section.  Now, all you need to do is create a rule and then choose your AppleScript from the pull-down menu.  Open Preferences > Rules > Add Rule.  

Create your filter however you want, and then on the last line choose to run an a script.  Select yours from the pull-down menu.  You are all set!

iloveautomation

Now anytime a message arrives that matches your criteria, an auto-response email will get sent (you will see a progress bar on the bottom right so you know that it is working).

auto-reply-working

4 Replies to “OS X Mail: Create HTML-formatted Auto-response With AppleScript and Rules”

  1. Hi there, this script looks great in theory but when I try to run it in Mail on El Capitan it just sends back a blank message

    1. Yes, I forgot to mention in the article, that you need to allow AppleScript and Mail access to assistive devices in order for it to work properly.

  2. This article is pretty old but i was wondering if you could help me, I am having the same problem as the other guy being the fact that it will reply with blank messages, I have given the mail app and applescript acess to assistive devices so i was wondering what the problem might be. Hope you can answer :).

    1. If you use the script above as-is, does it work? I recall that if the HTML was not escaped properly, it would just be blank. Another troubleshooting tip I use is to replace the action with the say command for each line of code so I know where the script is failing.

Leave a Reply