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.


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...
 

Add a Comment

*0 / 3000 Character Maximum

5 Comments

Filter by:
tonedef

Dear tuaw bloggers,
I am trying to find an app to use specifically with an autistic student that I work with. It is a scheduling app that would have icons or pics alongside a time during a day (e.g. 4:00-art-pic of art studio). As well, for easy choosing something he likes, a managing app that has folders and subfolders, and for those folders, being able to create personal pic skins or use icons...something like noteskinner+ if you have seen that app. Any suggestions would be appreciated! If not, if you are interested in developing unique like this, I would love to discuss further business prospects.
Thank you,
Tony C.

September 22 2008 at 3:03 PM Report abuse rate up rate down Reply
xenolon

i write applescript all the time, but i never thought to make one to do this. i wish i had. nice work.

August 05 2008 at 7:46 PM Report abuse rate up rate down Reply
Wilder

How do you change which calender it associates the to-do with?

August 05 2008 at 4:27 PM Report abuse rate up rate down Reply
Jonathan

Great idea! I set Mail to redirect email containing invoices to my Toodledo account (which didn't require the applescript), which will automatically create new todo's for me with the contents of the email in the notes. Score!

August 05 2008 at 2:16 PM Report abuse rate up rate down Reply
paul merrill

I am not sure about AppleScripts, but I *am* sure that tuaw is *way* better than theappleblog dot com.

Keep up the great work!!

August 05 2008 at 1:25 PM Report abuse rate up rate down Reply
Buy an ad here

Hot Apps on TUAW

Tweets

© 2012 AOL Inc. All Rights Reserved.