Hello all,
I’m looking for some help with something that seems pretty simple but I’m having trouble getting it to work, so…
I’m creating a custom url using my application which is in the form of testapp://t=1&q1=23&q2=35
Now, creating the link is not a problem, and the link works as expected with my application.
I’m trying to send this link by email as a clickable link with a title,
I found some code to store this in the clipboard as a link, but how can I store it in a variable to put in the email?
set currentCustomLink to "testapp://t=1&q1=23&q2=35"
shareLinkByEmail(currentCustomLink)
on shareLinkByEmail(theLink)
if theLink ≠ "" then
set myURL to createURL("Custom link", theLink)
try
tell application "Mail"
set newMessage to make outgoing message with properties {visible:true, subject:TestApp - Custom Link", content:("
The custom link is: " & myURL & "")}
tell newMessage
make new to recipient with properties {address:""}
end tell
end tell
end try
end if
end shareLinkByEmail
on createURL(linkText, theURL)
set strHTML to quoted form of ("<font face=\"helvetica\"><a href=\"" & theURL & "\">" & linkText & "</a></font>")
set theURL to do shell script "echo " & strHTML & " | textutil -format html -convert rtf -stdin -stdout | pbcopy -Prefer rtf"
return theURL
end createURL
Now, the example above doesn’t work, if I remove the part just before do shell script and don’t include the URL in the email it is stored in the clipboard correctly and I can paste it, but how can I skip the clipboard and have an rtf clickable link in mail?