David Sparks Recent Great Webinar About Automating Apple Mail

Hi all,

Less Labor On Labor Day!

David Sparks recent webinar about Automating Apple Mail was great. One of my favorite parts was how David has been using Apple Mail "message id" to create links to put in other programs.

So from his very cool AppleScript - I made a few updates for my own personal use and am loving how this all works.

For my version, when the AppleScript triggers it will paste 3 lines into the clipboard like:

Message from: [xxxemailxxx]
Subject: [xxxSubjectxxx]
Message URL: message://%[xxxreal message-idxxx]%3e

This text can be pasted wherever you like into whatever program like Filemaker - DevonTHINK - Obsidian - Apple Notes - Reminders etc...

I'm sure I will get a ton of use out of this new functionality.

Here is the simple AppleScript code with these slight mods that came from David Sparks original idea.

	-- From David Sparks - Automating Apple Mail webinar
	set selMessages to selection
	if (count selMessages) > 0 then
		set thisMsg to item 1 of selMessages
		set thisMsgURL to "message://%3c" & (message id of thisMsg) & "%3e"
		tell me to set the clipboard to "Message from: " & sender of thisMsg & return & "Subject: " & subject of thisMsg & return & "Message URL: " & thisMsgURL
		display notification "Message from" & sender of thisMsg & ", subject: " & subject of thisMsg with title "Message Copied"
		display notification "Nothing Selected"
	end if
end tell
1 Like

I think you need to wrap the code in tell application "mail" .... end tell block for it complie in Script editor, otherwise it works great
Also returns only the first selected message

I sat through the webinar also. This was the best bit and I added it to my macros. Thanks for those enhancements to provide more context than just the link. As lucky says, the beginning tell statement is missing. I don't mind that this only gets a link for the first message as that is how I would normally use it.


I watched David's amazing webinar as well and I have a question about moving messages to different mailboxes using shortcuts he explained.

In the video I moved one message to the Process folder, but moving it takes me to the top of the list.

Can I change that behaviour?

I've reached to David about this but maybe I'm in his "Black Hole" folder :man_shrugging:

Thanks for any suggestions!

Can you?

Nyet, and da.

Another great example of Apple's regular failures at understand basic UI.

There's no setting to fix this – bark loudly at Apple, and tell them this is bad behavior.

(It took me years to get them to do something similar in the Finder.)

Feedback - macOS - Apple

AppleScript UI-Scripting is your only programmatic option, and it is not for the faint of heart.


1 Like