Back to Mobile View

Skip to Content

AppleScript: Creating To-Dos in iCal


Recently, a friend asked me to create an AppleScript that would allow him to automate To-Dos with a Mail.app mail rule. I immediately rose to the occasion because this was a cool idea: Mail.app could run the script when you get an ebill, for instance, for your car payment. The script would then create an iCal To-Do for "Pay your car payment, now!"

The script
set theSumm to "Pay My Bill Soon!"
set dueDate to (current date) + 10 * days
set theUrl to "http://www.paymybillexample.com"
set thepriority to 1

tell application "iCal"
make todo at end of events of (item 1 of every calendar) with properties {summary:theSumm, due date:dueDate, url:theUrl, priority:thepriority}
end tell


Customizing the script
To customize the To-Do's title, fill in the text you want, within the parenthesis on line 1. To Change the due date, change the "10" in line 2 to the number of days until it is due. If you want to change to weeks or months, use the appropriate wordage instead of "days" at the end of line 2. To change the URL, paste a URL in the parenthesis on line 3.

By default, the script will set the newly created To-Do to have a priority of 1, however, you can change this to your priority preference.

Continue reading to learn how to integrate the To-Dos with a Mail.app mail rule.

Saving the AppleScript

Save the AppleScript by clicking File > Save in the Script Editor. Type in a file name and make sure the "File Format" is set to "Script" before clicking the save button.

Creating the Mail rule

To link all the parts together, let's create the Mail rules. Open Mail.app's preferences (command + , ) then click Rules. Click the "Add Rule" button. Type a description and select "All" for the "If ALL of the following conditions are met."

Now let's add the conditions (you will have to click the plus sign to add more conditions):
  1. From ... Contains ... mypayment@bank.com
  2. Subject ... Is Equal To ... Your Monthly Statement
  3. Message Content ... Contains ... Car
Add these rules under "perform the following actions" :
  1. Set Color ... of Background ... Blue
  2. Run AppleScript ...
For the run AppleScript rule, click the choose button and find your AppleScript that you just made. Then click the "Choose File" button.

You will need to customize the Mail rule to your specifications based on how you receive your mail, etc.

Running the Script
Whenever you get an email that matches the mail rule that we created, the script will run and create a new To-Do based on the specifications we made in the AppleScript. You can use this script for more than just remembering to pay your bills: it could also be used for remotely creating ToDos via your iPhone (similar to the way we created the AppleScript here).


Note on Mac Automation/AppleScript posts: We're moving to a 2x monthly frequency for the AppleScript how-to posts. You should normally see these posts on the first and last weeks of the month. As always, we invite you to send in script requests via our tip line.

© 2014 AOL Inc. All Rights Reserved.