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"
	else
		display notification "Nothing Selected"
	end if
end tell

Hi
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
Cheers

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.