Amending mail to OF script

I have a script called mail to OF which can be called to open an Omnifocus quick entry window from mail with a link back to the message URL. It works quite well, but I would like to amend the script to pick up the project assigned from mail Tags to automate the process a little (and possibly make the tickle date in Mail Tags the OmniFocus due date if I’m feeling ambitious!). I have appended the script I am using below. I have seen scripts here which are supposed to do that, but they don’t seem to work with latest versions of Sierra & Omnifocus. The syntax look quite different to my existing script (see below). Can anyone help me achieve my ambition please?


– Send currently selected message to OmniFocus 2 quick entry box, then archive it
– Archive behaviour found at:
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 my_subject to the subject of the selected_message

set message_url to "message://%3c" & message_id & "%3e"

set _mb to mailbox of selected_message
set _acct to account of _mb
set _archive_box to _acct's mailbox "Archive"

tell application "OmniFocus"
	tell quick entry
		make new inbox task with properties {name:my_subject, note:message_url}
	end tell
	-- tab into subject pane
	tell application "System Events"
		keystroke tab
	end tell
end tell

move selected_message to _archive_box

end tell