View Single Post
Here is a script I wrote that sends a selected mail message to the Quick Entry panel. This will create a new task with a name set to the subject line of the email and the content of the message as a note. Seems to work pretty good.

The only thing I don't like is that, when Quick Entry opens, the buttons have focus. Anybody know how to shift focus to the task window?

Hope this helps!

Code:
(*	New OmniFocus Action from Mail.app Message

	Written by Adam Sneller 
	Copyright October 10, 2007.  All rights reserved.
	
	Version 1.0

*)

tell application "Mail"
	
	-- get the currently selected message(s)
	set these_messages to selection
	
	-- if there are no messages selected, warn the user and then quit
	if these_messages is {} then
		display dialog "Please select a message first and then run this script." with icon 1
		return
	end if
	
	-- loop through messages
	repeat with this_message in these_messages
		
		-- create link to message
		set this_link to "message://" & (message id of this_message as string)
		
		-- create task content and link to message
		set this_subject to subject of this_message
		set this_content to this_link & return & return & this_subject & return & date received of this_message & ¬
			return & return & content of this_message
		
		-- send task to OmniFocus
		my pushToQuickEntry(this_subject, this_content)
		
	end repeat
end tell

on pushToQuickEntry(get_name, get_note)
	tell application "OmniFocus"
		tell quick entry
			set this_task to make new inbox task with properties {name:get_name, note:get_note}
			select {this_task}
			activate
		end tell
	end tell
end pushToQuickEntry