Brian, many thanks and these new script snippets work great! For those following along or who may stumble across this thread down the road, here's the final streamlined script:
Code:
-- FROM /OmniFocus.app/Contents/PlugIns/BuiltInClippingHandlers.plugin/Contents/Resources/Mail-Leopard.applescript
-- Trims "foo <foo@bar.com>" down to "foo@bar.com"
on trim_address(theAddress)
try
set AppleScript's text item delimiters to "<"
set WithoutPrefix to item 2 of theAddress's text items
set AppleScript's text item delimiters to ">"
set MyResult to item 1 of WithoutPrefix's text items
on error
set MyResult to theAddress
end try
set AppleScript's text item delimiters to {""} --> restore delimiters to default value
return MyResult
end trim_address
-- BASE SCRIPT FROM http://forums.omnigroup.com/showthread.php?t=6182
set messageCount to 0
tell application "Mail"
-- GET THE CURRENTLY SELECTED MESSAGE OR MESSAGES
set selectedMessages to selection
-- IF THERE ARE NO MESSAGES SELECTED, DO NOTHING
if selectedMessages is not {} then
set messageCount to count of selectedMessages
repeat with i from 1 to messageCount
-- parse the email(s)
set theMessage to item (i) of selectedMessages
set theName to subject of theMessage
set theMessageID to (content of header "Message-Id") of theMessage
set theMessageID to my trim_address(theMessageID)
set theMessageURL to ("message:<" & theMessageID & ">")
-- CREATE NEW TASK IN QUICK ENTRY
tell application "OmniFocus"
activate
set theTask to theName
set theNote to "Original Message"
tell quick entry
set NewTask to make new inbox task with properties {name:theTask, note:theNote}
set value of attribute "link" of style of note of NewTask to theMessageURL
end tell
end tell
end repeat
end if
end tell
-- SELECT TASK & EXPAND NOTES FOR FINAL MANUAL EDITING
tell application "OmniFocus"
-- OPEN QUICK ENTRY DIALOG
(get class of quick entry) -- Added to initialize Coca Scripting
open quick entry
tell quick entry
repeat with i in every tree
set note expanded of i to true
end repeat
-- SELECT TASK TEXT FOR MANUAL EDITING IF REQUIRED
select first tree
tell application "System Events"
keystroke tab
end tell
end tell
end tell