Filed under: Features, How-tos, AppleScript
AppleScript: Creating To-Dos in iCal

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):
- From ... Contains ... mypayment@bank.com
- Subject ... Is Equal To ... Your Monthly Statement
- Message Content ... Contains ... Car
- Set Color ... of Background ... Blue
- Run AppleScript ...
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.

![TUAW [Cafepress]](http://www.blogsmithmedia.com/www.tuaw.com/media/tuaw-cafepress-promo.png)


Reader Comments (Page 1 of 1)
paul merrill said 1:25PM on 8-05-2008
I am not sure about AppleScripts, but I *am* sure that tuaw is *way* better than theappleblog dot com.
Keep up the great work!!
Reply
Wilder said 4:28PM on 8-05-2008
How do you change which calender it associates the to-do with?
Reply
xenolon said 7:46PM on 8-05-2008
i write applescript all the time, but i never thought to make one to do this. i wish i had. nice work.
Reply
Jonathan said 11:58PM on 8-15-2008
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!
Reply
tonydef said 3:05PM on 9-22-2008
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.
Reply