I need to create an email to todo action in mail.app

Discussion in 'Mac Programming' started by iLuvBeba, Aug 30, 2009.

  1. iLuvBeba macrumors newbie

    Aug 30, 2009
    I am a bit of a newbie to Mac... I've done some programming in Visual Basic and have a decent understanding of programming. However I am a bit stumped.

    I would like to create a script that allows me to select the current email in Apple's Mail app and create a new task that passes the subject line to the Title of the task and the email body as the notes to the task.

    I am using Snow Leopard with Exchange as my email accounts.

    I am continuing to scour the forums, but if anyone can help me get pointed in the right direction, I would greatly appreciate it!

  2. MKSinSA macrumors regular


    Aug 1, 2009
    Alamo City, Lone Star State
  3. iLuvBeba thread starter macrumors newbie

    Aug 30, 2009
    Okay... now what about automator?

    Thanks for the push in the right direction! It paid off. Here's what my final script looks like. Works like a charm.... almost!

    using terms from application "Mail"

    set dueDate to (current date) + 3 * days

    set question to display dialog "Enter a GTD context to preceed the subject:" default answer "@Computer" giving up after 7
    set GTDcontext to text returned of question

    tell application "Mail"
    set theSelectedMessages to selection
    set the selected_message to item 1 of the theSelectedMessages
    set theSubject to GTDcontext & ": " & the subject of the selected_message
    set theContent to "From: " & the sender of selected_message & (ASCII character 13) & (ASCII character 13) & the content of selected_message
    end tell

    tell application "iCal"
    make new todo at end of todos of calendar "Tasks" with properties {summary:theSubject, description:theContent, due date:dueDate, priority:medium priority}
    end tell
    end using terms from
    end try


    The dialog box works as expected when I run the script from the script editor... however, when I access the script inside of automator via a services command, it skips the dialog box... waits the designated 7 seconds and posts the task without ever giving me dialog box.

    Anyone have any ideas with this?

Share This Page