Run Custom AppleScripts in MailMate

Overview

Goal: In addition to recurring tasks that I need to do on a regular, ongoing basis, there are other sets of tasks that I need to do on a recurring but non-regular basis. For example, whenever a family begins a new adoption and sends us the information on the child(ren) being adopted, there’s a series of tasks that I need to do in order to get things rolling for them. This can happen at any time, and in order to make sure that I don’t miss anything for any child’s adoption, I’ve created an AppleScript that adds a new project to Things whenever I get that email. That’s an AppleScript that I want my Mac’s email client to trigger automatically.

Problem: MailMate doesn’t have an easy, built-in way to trigger a custom AppleScript. This is one thing—quite possibly the only thing—that Apple’s Mail.app does more easily than MailMate. But don’t despair. There is a way to do this with just a few minutes and some careful attention to detail.

Solution: For each AppleScript that you want to run, you have to create a custom bundle in MailMate, which isn’t nearly as intimidating as it might sound, even for a non-developer like me. In fact, I still don’t know how to define a bundle or properly describe it to someone else, but that hasn’t stopped me from successfully creating about a dozen of them. Let’s get to it.

Set Up Custom AppleScripts for MailMate Rules

  1. Go to ~/Library/Application Support/MailMate/Managed/Bundles and locate the Things.mmbundle file. I used the Things bundle as a template because I wanted to set up rules for my inbox that would create specific tasks and projects in Things based on certain criteria. (More on that in a future blog post.) But, since these tasks are created by AppleScript, you can use this bundle as a way to execute any other AppleScripts you might want to have MailMate execute automatically.
  2. Duplicate the file in the Finder, rename it, and open it with a text editor. I used TextWrangler, and it worked great for this. Whatever you do, though, do not open the original version of the Things.mmbundle file, because that, at the very least, will serve as your template for other custom AppleScripts in the future.
  3. Open the Terminal app. You’re going to need to generate three separate UUIDs for this by running the simple command uuidgen. Go ahead and run it three times, and then leave the Terminal window open so that you can copy those UUIDs and paste them into the bundle at the appropriate spots.

    NPW MailMate Bundles 2.png

  4. In the Add With Summary section (see sidebar), change the UUID near the bottom of the code with the first UUID generated in the Terminal.

    NPW MailMate Bundles 3.png

  5. Do the same thing in the Add.mmCommand section, using the second UUID generated in the Terminal.

    NPW MailMate Bundles 4.png

  6. Make the same change in the info.plist section, using the third UUID generated in the Terminal.

    NPW MailMate Bundles 5.png

  7. In the info.plist section, also be sure to change the name of the bundle. This is the name that will show up in the Command menu in MailMate. If you don’t change it from Things.bundle, MailMate will only list one Things bundle but won’t know which one to trigger. So be sure to follow this step.
  8. Save the new text bundle.
  9. Relaunch MailMate.
  10. Set up your mail rule for your inbox, and enjoy the rush when your AppleScript is triggered by an incoming message and your Mac does precisely what you wanted it to do.
Advertisements