How to attach a reference to an email?

Often I need to refer to an email associated to a task (or an email thread). Is there some way to reference an email discussion thread in Omnifocus 2 from either Mac Mail or Outlook?

Sure. Select the text in the email that you want, then right click it and use the OmniFocus: Send to Inbox and it will create a new Inbox task with the selected text, and a link to the email that’s clickable.

This is an OS X Service and has always been present in OmniFocus. If you don’t have it showing up in the contextual popup menu, go to System Preferences->Keyboard->Shortcuts->Services and ensure that OmniFocus 2: Send to Inbox is enabled.

You can even give it a keyboard shortcut, if you want ;-)

thanks for the response!

I’m not trying to turn an email into a task. I already have a task that has information related to it in an a changing discussion thread inside of Outlook or Mac Mail.

When I’m referring to a task or project, especially if it’s been a couple of days I need to refresh my memory and read through the email thread related to to that task or email.

Are you suggesting that I create a task from my email anyway, then copy the related link that I need and put it in the other existing task, then delete the one created with send to inbox?

Well, there are a few alternatives…

You can drag and drop an e-mail message from Mail into the OmniFocus “Notes” field. However, for whatever reason, this doesn’t work with the “Notes” field in the Inspector on the right (I’m pretty sure I reported this bug a few months ago, but it doesn’t look like it’s been fixed yet)… so you need to make sure you drag the message to the in-line notes field below the task, which you’ll need to have expanded first by clicking on the note icon or pressing CMD+’

Another option is to look to plug-ins… I don’t know if anybody has created a current plug-in solely for the purpose of grabbing message links, but if you’re using MailTags, there’s a Copy Message URL option that can be found on the “Edit” menu in Mail. MailTags also has the advantage of letting you tag your e-mails with keywords and project names, and can read your OmniFocus database directly to populate your project list. It won’t link things, but at least you’ll be using the same project names in both apps.

The third method is to go with an AppleScript to do this. A script like the following would do the trick:

tell application "Mail"
	set _sel to get selection
	set _links to {}
	repeat with _msg in _sel
		set _messageURL to "message://%3c" & _msg's message id & "%3e"
		set end of _links to _messageURL
	end repeat
	set AppleScript's text item delimiters to return
	set the clipboard to (_links as string)
end tell

Paste that into Script Editor and run it as required. You could also use something like FastScripts to assign it to a keyboard shortcut.

The script is an easy way, but I’ve also been looking at Mail Tags. I’ll give both a try and write back to this thread.

thanks!

You used to be able to drag emails from Apple Mail into the notes section of the quick entry panel.

Since OF2 the notes line isn’t spring-loaded any more, so you have to manually open the notes link. It’s also not maintaining the email reference location after it’s moved.

I’ve also noticed after a recent update that even the email link is no longer displaying properly.

Any ideas on solving this? Will submit to as a bug as well.

Andrew

One caution about pasting message urls is that the link will only remain valid if the message remains in the same mailbox. So, if you like to keep a clean inbox, you should move the message before getting the url.

Also, I’ve always been told that the text item delimiters need to be returned to the default setting like so

tell application “Mail”
set _sel to get selection
set _links to {}
repeat with _msg in _sel
set _messageURL to “message://%3c” & _msg’s message id & “%3e”
set end of _links to _messageURL
end repeat
set oldDelimiters to AppleScript’s text item delimiters
set AppleScript’s text item delimiters to return
set the clipboard to (_links as string)
set AppleScript’s text item delimiters to oldDelimiters
end tell

Hi, I know this issue was from quite a while ago.
I’m wondering if there are any updates to this.

I could be wrong, but I thought I remembered being able to click and drag the email icon on the top of any email (from apple’s Mail.app) over to the OmniFocus item, and it would consider it an attachment. I could then click the link anytime to pull up that email from within Mail.app. I could be misremembering…

This functionality would be tremendously useful, a huge number of my tasks involve long email threads, being able to link to them directly from within the task would save me a huge amount of time, I would absolutely love to see this functionality introduced.

1 Like

Hello! I don’t see a resolution to this question.

Could somebody from OmniGroup chime in? Being able to drag/drop an email message into a task note seems very useful and also seems rather straightforward from an API standpoint.

The easiest way I found was to actually use Reminder as the drop target. That links work well when copied into OmniFocus.

Please let us know if this feature will be added or not.

Thank you!

1 Like

Send to Inbox is great, but I would like the ability to grab the link to add to an OF task later. It may seem backwards, but I often add email-reply tasks to OF when I realize that I’ve forgotten to reply to an email and I’m on my iPhone. The best I can do is put it into the OF inbox right then, and process it later on my Mac.

But to really make it possible to act on the task, I need a link to the now-buried email. As I process my inbox, I’d like to be able to add that. A service to copy the link to the clipboard would allow me to paste it into the notes field of the OF task. (Dragging doesn’t work in Sierra; at best, it creates a new, blank action with the link. At worst, the link is incorrect or fails to appear.)

1 Like

You can drag the mail into the notes field of the OmniFocus task.
The dragging process starts in Mail…

And ends in OmniFocus

Hmm. Yesterday this was not working reliably on my Mac. Today it worked a few times if I had the notes field of the task as the active part of the window; then I could drag a mail message there. However, after a few successes, OF crashed. Yikes.

I just want a basic, reliable, copy and paste action. I don’t want to have to set up windows so I can drag between them, make sure the correct box is active, and then precisely drag a small icon onto a tiny target — especially if it’s going to periodically cause a crash.

Ah well, this a minor problem in an great application.

This is a first draft of a script.
You select:

  • One task in OmniFocus
  • One mail in Mail app (in a conversation, it gets the most recent message)

Then, you run the script and a link will appear in the note field of OF selected task (it display a dialog if the note field is not empty).
If you like it, I can improve it.

-- unlocked2412
-- V0.01

tell application "Mail"
	set theMail to item 1 of (get selection)
	set {messageSubject, messageID} to {subject, message id} of theMail
	set messageURL to "message:" & "%3C" & messageID & "%3E"
end tell

tell application "OmniFocus"
	tell front document
		tell content of front document window
			set lstTrees to selected trees
			if lstTrees ≠ {} then
				set theTree to item 1 of lstTrees
				set theValue to value of theTree
				if (note of theValue) = "" then
					set note of theValue to messageURL
				else
					display dialog "The note field of this task is not empty"
				end if
			end if
		end tell
	end tell
end tell
1 Like

Just got around to trying this out. This is a fantastic script @unlocked2412!

1 Like

I use AirMail 3. It doesn’t do drag and drop on split screen on my iPad, but I can ‘copy message link’ in the actions menu on the iPad. On macOS I can copy message link (edit menu) or drag and drop the message into the notes field of OF. If I archive the email the links in OF will still open up the message wherever it moved to.

Dispatch is able to do this as well. There is an add-on for Mac that opens up the generated links.

Thank you so much for providing this. I’ve tweaked it a bit.

I use it in alfred. My workflow is this: Select the email message in mail, select my task in omnifocus, run the script. It will take the currently selected email message’s title and message ID, and put that as the text in the top line of the notes field of the currently selected task, formatted with title, url (I also include sender)

tell application “Mail”
set theMail to item 1 of (get selection)
set theMessage to item 1 of (get selection)
set {messageSubject, messageID} to {subject, message id} of theMail
set messageURL to “message:” & “%3C” & messageID & “%3E”
set theBody to “message://%3C” & message id of theMessage & “%3E”
set theText to the subject of theMessage & " (From " & the sender of theMessage & “)”
end tell

tell application “OmniFocus”
tell front document
tell content of front document window
set lstTrees to selected trees
if lstTrees ≠ {} then
set theTree to item 1 of lstTrees
set theValue to value of theTree
set theNote to note of theValue
tell theValue to make new paragraph at before first paragraph of note with data (return as text)
tell theValue to insert theText at before first paragraph of note

  		set value of attribute named "link" of style of paragraph 1 of note of theValue to theBody
  		
  	end if
  end tell

end tell
end tell