Universal Apple Mail message URL

url-schemes
shortcuts
#1

I don’t know on which podcast I heard about it, although I suspect it was mentioned by John Vorhees (not certain), but I’m looking for the method to create a universal url for a message in Apple Mail such that, when this URL is added to any document (Notes, Agenda, Things, Fantastical, etc.), when tapped, it will take us directly to that message in Apple Mail.

Any help gratefully received.

1 Like
#2

You can drag a Mail message on iPad into OmniFocus or Drafts and it will insert the message link in the resulting task or draft.

Just checked and it also works (with nicer looking results) in Notes.

#3

The harder way requires you to be able to view the full source of the email - see

Or do it on a Mac.

#4

Thanks for this. I didn’t know you could drag a Mail message on iPad. I’ll check if it works for Agenda, etc.

The second method only works if there’s a date mentioned in the email - most mails to which I need to link don’t include dates in the body, just general info or attachments I need to reference.

I know a well-known member of the technorati worked out how to create a universal url that, I think, they turned into a shortcut.

I can’t remember if they discussed it on Mac Power Users podcast, App Stories or something else with Federico Viticci as one of the hosts.

I’ve tried a Google search but I don’t really have enough variables/know how to craft the search to pinpoint it.

#5

No, if you read all the way the author discovered it by using a calendar URL but later shows how to get the message ID from the source. Still awkward though.

#6

I’m not clear on how this works without the date in the email. Can someone elaborate?

#7

View the full headers of the email. The link is then going to be message:// followed by the value of the Message-ID field.

#8

I used the drag to OmniFocus feature to get the URL. But @MacSparky posted a great script you can use to get the URL from Apple Mail on your Mac. It works great with TextExpander. I use it regularly to put links to e-mail messages in Apple Notes.

AppleScript to Link to Apple Mail Messages

#9

How do you view the full headers in iOS?

#10

I use fastmail and the fastmail app allows you to view the full headers. It will depend on your email client - you can’t do it in Apple Mail. Even with fm it’s not at all convenient.

#11

Thank you @iPersuade!

I believe this is exactly what I was looking for (although I thought it was a guest of Mac PowerUsers that mentioned it, not one of the hosts :sweat_smile:).

1 Like
#12

Things’ email to Things feature is the only one of its kind that actually constructs a message: URL back to the initial email when you forward a message to your custom address. I didn’t think it was possible, but now that I know it is I wish Omnifocus (and IFTTT/Zapier for that matter) would build the same thing.

#13

Thank you @iPersuade and of course @MacSparky for the great script to use with apple mail.
Since I’m not a TextExpander user, but was searching a solution for linking directly to mails a long time ago (I gave up until I saw your post and got motivated again).
Now I adapted the script to directly add all selected (not just the first) mail as links with their subject as title for the link to Drafts or Todoist. This works on the Mac with the URL schemes of the two apps.
If someone needs them here you go:

add selected mails to todoist:

tell application "Mail"
	set _msgs to selected messages of message viewer 0
	if (_msgs is not equal to missing value) then
		repeat with _msg in _msgs
			set _msgID to do shell script "/usr/bin/python -c 'import sys, urllib; print urllib.quote(sys.argv[1])' " & (message id of _msg)
			set this_subject to (subject of _msg) as Unicode text
			set encoded_subject to do shell script "/usr/bin/python -c 'import sys, urllib; print urllib.quote(sys.argv[1])' " & quoted form of this_subject
			
			open location "todoist://addtask?content=[" & (encoded_subject) & "](message://%3C" & (_msgID) & "%3E)"
            # add delay and press return to give todoist enough time to process the input
			tell application "System Events"
				delay 0.3
				keystroke return
				delay 0.3
			end tell
		end repeat
	end if
end tell

add selected mails to Drafts:


tell application "Mail"
	set _msgs to selected messages of message viewer 0
	if (_msgs is not equal to missing value) then
		repeat with _msg in _msgs
			set _msgID to do shell script "/usr/bin/python -c 'import sys, urllib; print urllib.quote(sys.argv[1])' " & (message id of _msg)
			set this_subject to (subject of _msg) as Unicode text
			#		delay 1
			
			
			set encoded_subject to do shell script "/usr/bin/python -c 'import sys, urllib; print urllib.quote(sys.argv[1])' " & quoted form of this_subject
			
			open location "drafts5://x-callback-url/create?text=(" & (encoded_subject) & ")[message://%3C" & (_msgID) & "%3E]"
		end repeat
	end if
end tell
2 Likes