Copy Mac Mail Title & URL to Clipboard

Hi there,

I currently use a workflow to drag a Mac Mail item to Rich Text Editor which creates the title of the email that's linked to it's source (for example message:%3C85EB6...), which I then paste into WorkFlowy. Is there any possible way to accomplish this with real-javascript (or any other way), meaning... to copy a Mac Mail title & URL to the clipboard?

If so this would be so amazing!!!

Thanks!
Craig

try this with the run real java script action:

(async ()=> {
let messageIDScript = `
   tell application "Mail"
	set _msgs to selected messages of message viewer 0
	if (_msgs is not equal to missing value) then
		set _msg to first item of _msgs
		return message id of _msg
	end if
end tell
`;

let messageID = await runAppleScript(messageIDScript);

let messageSubjectScript = `
   tell application "Mail"
	set _msgs to selected messages of message viewer 0
	if (_msgs is not equal to missing value) then
		set _msg to first item of _msgs
		return subject of _msg
	end if
end tell
`;

let messageSubject = await runAppleScript(messageSubjectScript);


let html = `<a href="message://%3C${messageID}%3E">${messageSubject}</a>`;

await set_clipboard_content({content:html, format: 'NSPasteboardTypeHTML'})

returnToBTT(html);

})();

Can be optimized for sure, but should do the trick. However like this it will only be possible to paste in apps that support HTML

Oh my goodness!!! This is so perfect! Pastes perfectly into WorkFlowy, which supports HTML, enabling me to link back to pertinent mail. You just made my day!
Thanks!!!

1 Like