Spent some time figuring it out myself, here's how for those that find this thread.
First make a mail rule that collects the messages you want it to collect. I've attached a screenshot of one of mine.
The "Amazon Order Shipped" script is this:
Code:
using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
tell application "Mail"
set theMailCount to (count of theMessages)
repeat with counter from 1 to theMailCount
set msg to item counter of theMessages
set theAttachmentCount to (count of mail attachments of msg)
set _title to subject of msg
set _sender to sender of msg
set _notes to the content of msg
set _combined to "message://%3c" & msg's message id & "%3e" & return & return & _title & return & return & _notes
tell application "OmniFocus"
tell default document
set theContext to (first flattened context where its name = "Computer")
set newTask to make new inbox task with properties {name:"Add tracking number to package tracking application.", note:_combined, flagged:true, context:theContext}
end tell
end tell
end repeat
end tell
end perform mail action with messages
end using terms from
This can be really, really easily modified for almost any use that involves collecting emails. I've made multiple Applescripts for each use of mine, changing appropriately this part:
Code:
set theContext to (first flattened context where its name = "Computer")
set newTask to make new inbox task with properties {name:"Add tracking number to package tracking application.", note:_combined, flagged:true, context:theContext}
To whatever context and title I want.
Pretty simple stuff, but hope this helps someone.