Hello,
I use the following macro to insert a Markdown link to the currently selected email in Apple Mail (I use it to insert the link into Bear Notes which are in Markdown format).
It is not elegant having to activate Mail which flashes on the screen then return to last application.
I think that I offended you and I apologize profusely. My question was poorly formulated and gives the impression that I do not give you proper credit for a brilliant macro that I use many time every day.
My question is: suppose I am working in a markdown Bear note and while in Bear I want to insert a link to the currently selected email in apple mail, is there any way to do this without exiting bear β activating Mail β triggering your excellent macro β coming back to Bear β paste Markdown link. It's the navigating apps part that I want to try to avoid.
You have been a huge help over the years, on many occasions, and once again, I am very sorry.
I will offer up an AppleScript that I use in other macros, slightly modified to return a link. Caution: I did not write this myself, it's regurgitated crud from an AI, but it seems to work fine.
If you have multiple items selected, it returns the first of them.
tell application "Mail"
set selectedMessages to selection
if selectedMessages is {} then
return "No message selected"
else
set theMessage to item 1 of selectedMessages
set messageURL to "message://%3c" & message id of theMessage & "%3e"
return messageURL
end if
end tell
You'll then have to invoke @ComplexPoint's macro, or do whatever, to get it into a markdown link format.
@ComplexPoint's macro designed to create a markdown (or similar) link to the selected item in the frontmost app -- you want to get a link to the selected item in Mail when Mail isn't frontmost. You can do that without activating Mail by using AppleScript/JXA (an option not available for many of the apps Rob's macros can handle), as @griffman's shown.
Luckily, Rob's used JXA to do the hard work of getting/formatting the link text in the "com.apple.mail" macro in the "MD link tools" Macro Group -- and it doesn't require Mail to be frontmost! It saves the text in the global variable mdLink, so all you need to do is execute that macro then insert the contents of mdLink: