Applescript create URL from text

Try this. It’s also derived from the ‘Selecting text and…’ post. It will deposit the subject of a message (and a link to it) into the first empty child of the first topic. I hope this is basically what you’re looking for.

I got the ‘message’ URL format from this page: ‘message:’ URLs in Leopard Mail
There are several variants. I picked the second one. You can read why there.

tell application "Mail"

	-- pick a message, any message
third message of mailbox 1 of account 2
set targetMess to third message of mailbox 1 of account 2

-- get subject and message ID
set subLine to subject of targetMess
set messID to message id of targetMess
	
	-- create message URL for desired email
	set fUrl to "message://%3c" & messID & "%3e"

end tell
tell application "OmniOutliner"

	-- a place to save the link
	set d1 to document 1
	set c1 to first child of child 1 of d1 whose topic is ""
	
	-- make (subject and message url) into (topic with link)
	set topic of c1 to subLine
	set c1's topic's style's attribute "link"'s value to fUrl
	
end tell