Create iCal To-do: Applescript for Apple Mail

In my last posting I shared a script I put together to use with the shortcut application Quicksilver to quickly create To-do items in iCal. I am now using this all the time. I have separate scripts, based on the same which create a medium priority “READ: ” to-do for things I want to put on my reading to-do list, a “LOOKUP: ” medium priority script to remind myself of things I want to look up at some point (assigned to a different color calendar), and a high priority to-do script in its own iCal calendar.

Now, what if I’m away from home, am without my laptop computer, but have access to a nearby terminal with an internet connection, and I want to create to-dos for myself. I synch iCal with my Palm pilot so I could easily write down the to-do directly into my Palm. However, Palms are still not fun to use when you have a lot to write down. Today, I was in the Fung library reading some Chinese historical journals and wanted to remind myself to look up a few things I found there and come back and read some articles I didn’t have time for today. There were internet terminals all over the place so instead of entering the titles (in Chinese) on the Palm, which is a pain and time consuming, I emailed myself some email messages with the subject “LOOKUP: ” or “READ: ” and then what I wanted to lookup/read. In the body of the email I put more information, such as a URL or notes to myself. I decided that tonight when I came home I would hack up an applescript that used Apple’s mail filter to automatically find those messages as they arrived in my inbox, create the appropriate to-do in iCal (like the Quicksilver script) with the subject line of the email, put the body of the email into the todo’s notes, and then move the message into an archived folder. The results are below.

The first and last of these can be done with a filter in Apple mail that looks like this:
Apple Mail Rule

The script itself can be downloaded here, and the full text of it is below. You may have to change the name of the calendar you assign it to in order to suit your own needs:

using terms from application “Mail”
on perform mail action with messages theMessages for rule theRule
tell application “Mail”
repeat with eachMessage in theMessages
set theSubject to subject of eachMessage
set theContent to content of eachMessage
try
tell application “iCal”
set newtodo to (make new todo at end of todos of calendar “Projects”)
tell newtodo
set priority to medium priority
set summary to theSubject
set description to theContent
end tell
end tell
end try
end repeat
end tell
end perform mail action with messages
end using terms from

8 thoughts on “Create iCal To-do: Applescript for Apple Mail”

  1. I have been searching for a script to do exactly this. Thanks very much for putting this together.

  2. I’m curious whether it’s possible to modify this script to add new events instead of to dos. For example, I get emails that are task assignments. The email subject line would read something like “New Task Assignment: Put DVCAM in Room 706″. I would want this info to be placed in the New Event section. The ‘location’ wouldn’t be as necessary because the info is already in the New Event section. Then the body of the email contains all the information for the given task. This would be put in the notes section of the event. The calendar would be set to “Work”. The ‘from’ and ‘to’ sections would be filled in with the DUE information from the body of the email. Perhaps, the ‘from’ time can be set as 1 hour before the task is due. The ‘to’ is set to when the task is due. Hopefully this all makes sense. The purpose of all this is to have events that can be syncronized to an iphone.

    This is what the body of an email typically looks like:

    TASK NAME: Please install DVCAM deck and media dock in Rm706
    ASSIGNED BY: Shikha
    PROJECT: Absence
    CATEGORY: DECK RENTAL
    DUE: Monday, February 25, 2008 10:00:00 AM EST
    PRIORITY: 2-Normal
    STATUS: 1-Not Started
    ASSIGNED TO: Scott
    VISIBLE TO: Scott

    DETAILS:
    Please install a DVCAM deck and media dock in Rm706.

    BISP is using the room all week till Fri 2/22.
    Installs will need to be done first thing Mon 2/25 AM so the editor for “absence”
    can start @ 10a.m.

    Thanks!

    To access the task in the web office, click the link below:

  3. I’m wondering if you can help me with something. I want to create a script to do something very similar. I have an email address set up just for emailing myself (or other people emailing me) events. I don’t work well with to do lists, but I manage a lot of events. I have already set up iCal to automatically publish changes to a phpiCalendar installation on my website. What I want to do is automate the process of taking the email and creating an iCal event out of it. Leopard Mail already has a lot of the recognition built in, so I’d like to utilize that if I can. For instance, it will take the subject of an email as the event title and parse the email for times and dates.

    A typical email I send to myself is something like this

    subject: picnic @ blackhawk park

    body:
    July 19
    4pm – 6 pm
    calendar: home
    notes: bring a salad & drinks

    Can you give me some tips on how to create an applescript to do that? I’ve already got the mail rule set up to filter messages coming to that email account into a folder. I just have never used applescript before, so it’s kind of intimidating.

    Thanks – Adam

  4. I just wanted to say thanks, your script has been very helpful, i’ve been testing entourage just because i couldn’t create tasks from Mail directly, but I found it not reliable enough.

    Thanks to you, now I am back to my initial Mail / iCal setup!
    Greetings from Spain,
    Victor

  5. Unquestionably believe that which you stated. Your favorite justification seemed to be on the internet the easiest thing to be aware of. I say to you, I definitely get annoyed while people think about worries that they just don’t know about. You managed to hit the nail upon the top as well as defined out the whole thing without having side effect , people could take a signal. Will likely be back to get more. Thanks

Comments are closed.