In this article, I will demonstrate how to use Apple Script and Automator to create reminders in Apple Mail and any other application via a shortcut. I have tested the described technique works in OS X 10.9 Mavericks and macOS 10.14 Mojave and all releases in between.
How to create reminders in Apple Mail
One feature I sorely miss in Apple’s Mail is the ability to flag an email for follow-up quickly and set a reminder or follow-up date. Microsoft Outlook 2011 has that ability, but I prefer to keep my workflows as streamlined as possible and that includes using Apple’s Reminders and Mail.
You can flag emails in Mail, and the flags synchronize via iCloud to iOS, but unfortunately, you can’t set a reminder or follow-up dates, and flagged emails on iOS only show in the “Flagged” mailbox if you leave them in their respective Inbox.
I keep a clean inbox and usually move every email that I have either processed or that requires me to wait for someone else before I can further process it into an archive mailbox.
So none of my flagged emails show in the Flagged mailbox on iOS. That makes flagging alone less useful as it already is due to lack of integration with Reminders.
A manual workaround for me has been to flag emails in Mail and then drag and drop them into one of my Reminders lists. There I can set a reminder date and check it off as complete when I’m done. Dragging an email into Reminders also conveniently adds a link to the email in Mail. This approach has worked well, but it still requires more manual interaction than I like.
Apple Script and Automator
So I was googling for alternatives and finally decided to approach the problem via AppleScript. I did some software development in the past but my programming skills are about on the same level as my handyman skills, and my wife can attest to how bad they are.
Nevertheless, after some research and trial and error, I managed to put together a script that, when triggered (via a keyboard shortcut or click on the service menu) creates an entry in Reminders and sets a remind me date based on user input.
It also flags the email in Mail. When running against an email whose subject matches an existing reminder, it asks if it should mark the reminder as complete and if so, does it and also unflags the email in Mail.
You can download the complete script from here.
Create a service in Automator
To trigger the script conveniently you want to save it as a Service and to do so, open Automator (a utility that ships with macOS) and select Service.
Next, search for AppleScript in the search bar and drag it onto the area on the right side. Select “no input” and “Mail” in the drop-down boxes.
Delete all the code in the AppleScript box on the right and paste the code of my script.
Make sure to change the following lines to reflect your account names in Mail and list names in Reminders. If you have only a single email account and Reminders list, just set both pairs to the same value. For example, iWorkAccountName = PersonalAccountName = iCloud and the same for *RemindersList.
WorkAccountName to "Exchange"
WorkRemindersList to "Work"
PersonalAccountName to "iCloud"
PersonalRemindersList to "Personal"
Additionally, you may want to change the flag color the script uses. I have seven flag colors in Mail, and #6 is Purple. Since the index in AppleScript starts counting at 0 instead of 1, I set FlagIndex to 5 below.
set FlagIndex to 5
If your system language is not set to English, you may also have to change the following line of the code:
#default list name in Reminders
set RemindersList to "Reminders"
Apple translates the term “Reminders” into the system language. For example, on a Dutch system, you would have to change Reminders to Herinneringen. Thanks to Gideon, one of my readers, for this tip!
Then click the “hammer” icon to compile the script and to make sure there are no syntax errors.
Finally, save the service script (Cmd + s) and give it any name you want. I called mine “Create reminder from email.”
How to use the service in Apple Mail
Now you may have to restart Mail to see the service under Mail -> Services -> Create reminder from email.
To test the script select an email and go to Mail -> Services -> Create reminder from email. You should see a dialog appearing like the one in the screenshot before. Once you have selected the preferred follow-up time, a reminder will be created, and the email will be flagged.
If you know AppleScript, you can quickly change the follow-up time choices.
If you run the script again on the same email the following dialog appears and allows you to mark the reminder as complete:
Last but not least you may want to add a keyboard shortcut, so you don’t have to go through Mail -> Services -> Create reminder from email all the time. To do so go to Mail -> Services -> Service Preferences and scroll down to General. Select the service you just created and assign a keyboard shortcut. In my case, I decided to use Cmd + Ctrl + R.
From now on pressing that key combination triggers the script. One thing I have noticed is that running the script in the AppleScript Editor is significantly faster than running it as a service.
Suppress privacy pop up
When you first run the service out of Mail, you may get a pop-up (depending on your version of macOS) asking if you allow Mail access to your Reminders. You have to say yes because otherwise, the script won’t run as indicated by one of my readers (thanks, Christian).
In case you haven’t said yes, or you don’t remember, you can verify if Mail has access to Reminders via System Preferences –> Security & Privacy –> Privacy –> Reminders. Make sure Mail is there and checked. You may have to click on the lock icon in the lower left corner to make changes.
How to create reminders from any application via a global shortcut
Let’s apply what we have learned above to develop a simple script that allows us to create a reminder via a global keyboard shortcut from any application.
The advantage of a global shortcut
As a global shortcut, as the name implies, can be invoked from anywhere, no matter what application you are in.
You can download the complete script from here.
Step by Step Instructions
Adding a Service using Automator and assigning it a global keyboard shortcut is simple. Here are the steps involved:
- Launch Automator
- Create a New Document
- Select Service
- Search for AppleScript and drag it over to the right side as an action
- Delete the sample code and paste in my script
- Make sure to select “Service receives: no input.”
- Compile it to make sure there are no syntax errors
- Save the Service. For example “Create Reminder”
- Close Automator
- Open System Preferences and go into Keyboard settings
- Go to Shortcut tabs and select Services
- Scroll down until you see your Service
- Click on “add shortcut” and press your key combination of choice
- I use Control+Option+Command+r
- Close System Preferences
To see if your new Service and keyboard shortcuts works press the key combination you have chosen, and you should see a dialog like the one in the screenshot below.
You have two options:
- Enter the subject name of the reminder only, such as “Buy milk” or
- Enter a prefix indicating the due date in hours, followed by a: and the subject. For example 2:Buy milk, which will add a due date of two hours in the future
If you do not enter a due date, the script will default to 2 hours. Of course, you can change that default value in the script to suit your needs.
Depending on the version of OS X you have, you may get the following dialog, asking if System Preferences can get access to your Reminders. Just click OK. You can double-check if the permissions were granted via the Privacy Settings.
Issues in macOS 10.14 Mojave (Beta)
Apple has made some changes on how macOS protects access to application data, and as a result, if you use the above scripts you will likely see an error message like in the screenshot below: The action “Run AppleScript” encountered an error: “Not authorized to send Apple events to Mail.”
I’m not aware of any workaround of this, but I expect Apple to fix the problem or give users a choice to allow access to Mail from the “Run Apple Script” event framework.
Shortcut to create reminders in Apple Mail and other applications
I hope you find my scripts useful and if you do, I’d appreciate if you left me some feedback. The code is released as-is, and you can use it where ever you want to.