View Single Post
Zooids,

Thanks for posting this! It is fantastic. I hope someone can make it even better.

For the script to work, this line has to reflect the context you are using in OF:

Quote:
set My_Context to "mail"
In other words, you would have to have a top-level context called mail.

I have prefer to use "email" so I changed my script to the following:

Quote:
tell application "Mail"
set theSelectedMessages to selection
set the selected_message to item 1 ¬
of the theSelectedMessages
set message_id to the message id of the selected_message
set message_url to "message://" & message_id
set message_subj to (subject of selected_message)
set message_sender to (extract name from sender of selected_message)
set message_content to summarize (content of selected_message as string) in 1
end tell

tell application "OmniFocus"
set MyDoc to first document
set My_Context to "email"
set My_Task to message_subj & " - " & message_sender & " - " & message_content

tell MyDoc
try
id of My_Context
on error
set new_Context to first context whose name contains My_Context
end try
make new inbox task with properties {name:My_Task, context:new_Context, note:message_url}
end tell
end tell
Note: you need a top level context called email.