Monday 12 November 2012

Fix AppleScript to create new tasks in Things

This fixes the problems highlighted here https://culturedcode.com/forums/read.php?7,59076 on the cultured code forum.

By making a series of changes to the script provided here https://culturedcode.com/things/wiki/index.php/AppleScript:Create_new_tasks_from_Mail_messages,_adding_Growl_notification using the code changes suggested here http://forums.macrumors.com/showthread.php?t=1416945 gives a script which creates a new Task when you receive a message with the title "Add to things" - you need to set a rule that runs the script on receiving a message with that as a title. It then creates a task in things with the task name the same as the description, so make the message body short!


using terms from application "Mail"
on perform mail action with messages newMessages
repeat with newMessage in newMessages
tell application "Mail"
set taskName to content of newMessage
set taskNotes to taskName & " (From " & the sender of newMessage & ")"
tell application "Things"
set newToDo to make new to do with properties {name:taskNamenotes:taskNotes}
end tell
tell application "Growl"
set the allNotificationsList to ¬
{"Task Created"}
set the enabledNotificationsList to ¬
{"Task Created"}
register as application ¬
"Create Task from Multiple Mail (Growl Enabled)" all notifications allNotificationsList ¬
default notifications enabledNotificationsList ¬
icon of application "Things"
notify with name ¬
"Task Created" title ¬
"Task created in Things" description ¬
taskName application name "Create Task from Multiple Mail (Growl Enabled)"
end tell
end tell
end repeat
end perform mail action with messages
end using terms from



At the moment the body contains line breaks, and makes the task format strangely in things, if you know how to add some code to remove the line breaks from the subject I would appreciate it!

Note you need to place this in the new place where Mail expects scripts to be, navigable via the rules definition screens under Mail preferences.




No comments:

Post a Comment