Systems Engineering

Creating Daylite Tasks From Mail App Script

August 15, 2009

  • Adrienne Szewczyk Adrienne Szewczyk
  • 4

We use Daylite for keeping most of our contacts and opportunities organized.  One of the few frustrations with it has been the inability to quickly pull Mail messages into Daylite as tasks so they could be acted on later as appropriate and not clog up the inbox.  In keeping with a Getting Things Done (GTD) mentality for task management I needed a solution.

After some net digging (thanks to John Gruber for his post on Mail messages ID URLs and ‘Casper’ for a basic way to push data into Daylite) I was able to find a couple pieces to start the process and pulled together the script below.  It will take any selected messages in Mac Mail and add them to Daylite as tasks.  The email subject line becomes the task name and the body of the task includes a message link that can be used to bring up the original email again (just right click or control click that link in the Daylite task and select open URL) and up to 1000 characters of the message body.

Example of ctrl-clicking on the message URL.

To install the script, download the file and put it into:


You may need to create that directory (it didn’t exist yet for me).

Then make sure your scripts menu is turned by.  Activate it using the Applescript utility (in Applications/Applescript/Applescript utility) and then check the ‘show script menu in menu bar’.

Now you can select the script ‘Add Daylite Tasks’ and it will add the new tasks to the Daylite Inbox.

This script has very little error handling so use at your own risk for now (and let me know if you find issues).

The final ease of use factor comes from using MailActOn which lets you set up a key combo to run a rule.  I’ve used this previously for quick sorting of messages to specific mailboxes so it just took adding a quick rule that runs this new Applescript. So my magic combos are ctrl-T for creating the task and ctrl-R to move it out of the inbox to a reference folder.


Mail to Daylite Task Script
©2009 Alex Bratton <>
Based on Mail2DL script by Casper Lassenius <>

This script is distributed as open source software
You are free to copy, modify and share parts of or the entire script, as long as you
a) Keep this notice in any modified version of the script
b) Transfer this notice to any derrivative work
c) Don’t charge money for this script or any derrivative of it

This software is provided “as is” without any warranty, explicit or implied.
The author of this software is not liable to any loss or damage of data that
may happen by installing or using it.

tell application “Mail”
set AppleScript’s text item delimiters to return
set _sel to get selection
set _links to {}
repeat with curMessage in _sel
set _messageURL to “message://%3c” & curMessage’s message id & “%3e”
set end of _links to _messageURL
set curText to subject of curMessage — subject from the ToDo’s summary
set bodylength to length of (content of curMessage as string)
if bodylength > 1000 then
set bodylength to 1000
end if
set body to characters 1 through bodylength of content of curMessage
set curBody to “”
repeat with theChar in body
if contents of theChar is “‘” then
set curBody to curBody & “””
set curBody to curBody & theChar
end if
end repeat
set curBody to reply to of curMessage & ”
” & curBody

tell application “Daylite”
eval ”
document := (NSApplication sharedApplication) firstDayliteDocument.
objectContext := document objectContext.

creation_context := objectContext creationContext.
new_task := creation_context createObjectForEntityNamed:’Task’ addToObjectContext:true.

new_task setTitle:'” & curText & “‘.
new_task setDetails:'” & _messageURL & ”
” & curBody & “‘.
new_task addToInboxForObjectContext: objectContext.
objectContext saveChanges.”
end tell
end repeat
end tell

Edit: Here’s a link to download the script as a zip file
Add Daylite Task script

Leave a Comment


Seems great to try, but . . . no cannot find the link to download it.

Reply to comment

Umm, call me stupid, but I can’t find the script.

Reply to comment

[…] This post was mentioned on Twitter by marketcircle and James Spencer, Lextech. Lextech said: How to create #Daylite Tasks From #Mail App Script @marketcircle […]

Reply to comment

Sorry, I am an AppleScript newbie and can’t get this to work.

I tried copying the script off the site into the AppleScript Editor (Mac OS 10.6.6). When I press the Compile button, I get the following Syntax Error:

“Expected expression, property or key form, etc. but found unknown token.”
with the quotation marks surrounding the word “mail” in the first line of the script, “tell application Mail” highlighted.

As Apple ScriptEditor won’t let you save the script when it can’t compile, I can’t even test it.



Reply to comment