Monday, December 9, 2019

#1 2019-10-16 06:36:39 pm

AoRaToS
Member
From:: Greece
Registered: 2019-09-01
Posts: 9
Website

send email containing custom link

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?

Applescript:

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?

Last edited by AoRaToS (2019-10-16 06:39:13 pm)

Offline

 

#2 2019-11-20 04:46:29 pm

AoRaToS
Member
From:: Greece
Registered: 2019-09-01
Posts: 9
Website

Re: send email containing custom link

Helloooo everyone,

Bumping this!
Does anyone know of a way of adding a link (any link) to the mac Mail application as described?

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)