Create a New Note From AppleScript

The discussions in this other thread may be directly relevant. In fact some of the scripts above in this thread bear a striking resemblance to scripts in that thread!

Plain vanilla AppleScript is not good at outputting rtf or quasi-rtf (or whatever it is) for the Tinderbox Text pane. I haven’t found a way to do that without going through the clipboard.

The discovery by @mwra that typing a character after a (plain text) url in Text makes it clickable is intriguing! (The “raw” link unfortunately looks a bit ugly but it could work if there were some way to trigger Tinderbox to look for and activate links.)

AppleScript can easily output plain text for the URL attribute in Tinderbox where it is immediately clickable. That’s why I suggest going that route rather than trying to place a link in the Text pane. It’s easy to implement.

But if your goal is to have a pretty link in the Text pane instead of, or in addition to, the URL attribute then you can convert the plain text message link AppleScript extracts from Apple Mail into rtf using textutil within an AppleScript and place the result on the clipboard for pasting into the Text pane as a clickable link that uses the subject line of the message.

This is a script as posted in the other thread that does this …

tell application "Mail"
	tell first item of (get selection)
		set theHTMLLink to "<a href=\"" & "message://%3C" & its message id & "%3E" & "\">" & its subject & "</a>"
	end tell
end tell
-- convert html to "rtf" link and place on clipboard for pasting wherever
do shell script "echo " & quoted form of theHTMLLink & " | textutil -format html -encoding UTF-8 -convert rtf  -stdin -stdout | pbcopy -encoding UTF-8 -Prefer rtf "

Here it is in a Shortcut, also posted in the other thread:
Mail Message URL to Clipboard

(Click with Safari to view/install Shortcut)

BTW, for recent macOS version, a Shortcut in the built-in Shortcuts app pinned to the menu bar may be more convenient than going the old Automator and Services Menu route. Either way, lots of things can be done quite easily without dependency on third-party apps.

1 Like