When I run it, I do not get a rich text link, but I get a string of Markdown. It is obviously getting all the right information about the Mail message, but I thought the Shortcut would return a rich text / “clickable” link. Am I misunderstanding the intent of the Shortcut? Am I missing something obvious?
Any help would be appreciated. Thanks!
-Eric
Here is the AppleScript:
on run {input, parameters}
tell application "Mail"
set _msg to item 1 of (get selection)
set _messageURL to "message://%3c" & _msg's message id & "%3e"
set _msgSubject to subject of _msg
set _from to sender of _msg
set _name to extract name from _from
set the clipboard to ("[" & _msgSubject & "](" & _messageURL & ")" & " from " & _name as string)
end tell
end run
It looks like you’re generating a Markdown link (looking at the AppleScript code) and saving it to the clipboard, which you could paste into a Markdown document, which would then give you a clickable link within that document.
I’m also trying to use the Shortcuts action “Make Rich Text from Markdown,” but that doesn’t seem to be working. When that action takes its input from the previous action (the AppleScript), and I then put that result onto the clipboard, when I paste, I still get a markdown string. When I set the “Make Rich Text from Markdown” action get its input from the clipboard, I get a generic error message from Shortcuts.
If I understand what you’re doing correctly, your shortcut runs the AppleScript action, which saves the link to the clipboard. Then it runs a Get clipboard action, passes that to the Make Rich Text From Markdown action. If this is what you’re doing, try changing the AppleScript to return the Markdown link (which will pass the link to the next action in your Shortcut) and getting rid of the Get Clipboard action.
Thanks! So I found a variation of the script that ends (before the “end run”) with “return input”. I then added the Shortcut action “Make Rich Text from Markdown” which automatically linked to the magic variable “AppleScript Result.”
Running this combination, when I paste it, alas, I still get the Markdown string, not a rich text link.
Again, I am sure that I am being boneheaded here and missing something obvious. I appreciate folks helping out!
I have tried it with and without that (“copy to clipboard” action), and get the same result, a Markdown string. I have also tried removing the part of the script that adds the recipient name, wondering if that was messing with the Markdown creation, so that the “set clipboard” line of the script reads:
set the clipboard to ("[" & _msgSubject & "](" & _messageURL & ")" as string)
But I still get a Markdown string instead of a rich text link.
Here is what I have been using. I can’t claim any authorship, it is John Voorhees, and any mistakes in it surely come from my tinkering. And any failure of it to do what it says is surely due to my lack of understanding.
Thanks to everyone who is helping me out with this!
The AppleScript in this shortcut is making a Markdown link, which works fine to paste into a Markdown-aware editor – it becomes clickable. It might be easier to help you troubleshoot and create a solution to know where you plan to paste the link, as different applications use different link syntax. Then potentially you could build a link in the script that’s more “native” to the target application.
So work and life got crazy, but I was finally able to follow up on this. Thank you to everyone for your help, and I have been able to cobble together something that basically works. I appreciate everyone’s time; you helped me figure this one out! Thanks!