Mail to Omnifocus script

I have some scripts to do this for some time, but have not used them for a while. On going back to them (triggering from Mail Act-on) they no longer seem to do anything. They may be old v2 scripts which no longer work. Does anyone have an up to date script which will use the mail title as a task title as a task is created in my inbox & links back to the e-mail?

Bill

Getting the email subject into an Omnifocus task is easy. But I have never tried or thought there was a way to ‘link’ back to the original email. I’d be interested in hearing about that as I don’t see an obvious way to do that.

Ok found this but it is old.
http://hints.macworld.com/article.php?story=20071118154803739
I’ll have to check if this is exposed to Applescript otherwise you’ll have to parse the email source to get it. I won’t have time today to play with this. Last few days of work before Xmas and they are gonna be tough. 🤷🏻‍♂️

If you use the option in the services menu it creates a link-back.

I want to automate this though via Mail Tags so I am looking for a way to duplicate the services menu functionality.

Right. That trick from OS X Hints for 10.5 actually works in Big Sur though and “message id” is easily extracted via applescript, so you can do what you want with Applescript. Try this:

tell application "Mail"
set theEmails to (get selection)
repeat with i in theEmails
	set tSub to subject of i
	-- message id in Mail Source will provide link back, but the < > must be URL encoded. 
	set tMsgId to (("message://%3C" & message id of i & "%3E") as string)
	tell application "OmniFocus"
		tell document "Omnifocus"
			make new inbox task at end with properties {name:tSub, note:(tMsgId)}
		end tell
	end tell
end repeat

end tell

I don’t get the point. I select an e-mail, use the service “OmniFocus 3 : Send to inbox” or the appropriate short cut. Then I have a new task in my inbox with a link back to the original mail in the task’s notes.

OP wanted an applescript that can do this so he can automate the process with Mail Act-On (a third party Mial extension: https://smallcubed.com/scs/) which allows you to set rules in Mail (like Mail rules but with added features and filtering). Mail Act On can’t access services, but it can run an Applescript automatically for you as soon as mail sees the email and applies the rule…without human intervention.

Second, if you are using Fastscripts, you can launch applescripts quickly just using a single key-combination to access the Fastscripts menu and then type the first few letters of what you want to launch the applescript from a list of your applescripts for that particular app…without having to memorize another key-combination.

OP agrees with you!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.