Mail.app in Lion – is there a way to create tasks from email

applescripticalmail.app

I'm not sure if I haven't seen that in earlier versions of Mail.app, but I would really love to have the ability to create a task in iCal from an email – and that this task could link to the original email.

Maybe there are some third-party solutions that would let this done easily?

Best Answer

It's possible to do that with AppleScript.

If you're familiar with this technology, you should just browse iCal and Mail respective dictionary. If not, that's the occasion to become familiar ! This is a great place to start.

Here's a very basic script you could use (tested on Snow Leopard only, but should work fine on Lion as well) :

tell application "Mail"

    set theSelection to selection
    set theMessage to first item of theSelection
    set theSumm to subject of theMessage
    set theDescription to "From : " & sender of theMessage
    set theUrl to "message:%3C" & message id of theMessage & "%3E"

end tell

tell application "iCal"

    make todo at end of events of (first item of every calendar) with properties {summary:theSumm, description:theDescription, url:theUrl}

end tell

In order to use it easily in Mail, you should save it in ~/Library/Scripts/Applications/Mail/ (create folders if they don't exist) and activates the Scripts menubar item in preferences of AppleScript Editor. Here's the result when you're in Mail :

enter image description here

You can also use a productivity tool to launch your script. There are plenty of them out there but I personally use Keyboard Maestro & Alfred.

There's a lot of room for improvement. By example, you could set a default alarm, insert it in a given calendar… In order to improve it yourself, use the AppleScript dictionary : it's the best reference you could find. However, those links may be useful as well, as they provide many examples (some are maybe too old) : Scripting Mail & Scripting iCal.