Problem with adding attachments stripping out formatting in signatures

I am having a problem with the formatted links in mail signatures being removed when I add an attachment to a mail message. I use signatures so that I can have links that look like: This Week’s News, instead of https://www.dropbox.com/s/b2errnkf3tu1nsj/FileName-001.pdf?dl=0.

If I don’t add an attachment to the mail message, the formatted links are fine. However, if I add an attachment, the links are deleted and don’t work. Here is the sample code:

set theNewMessage to make new outgoing message with properties {sender:"me@me.com", subject:mailSubject, content:theBody, visible:true, message signature:signature theSignature}
tell theNewMessage
     make new to recipient at end of to recipients with properties {address:theEmail}
     make new attachment with properties {file name:theAttachment} at after the last word of the last paragraph
     delay 5
     send
     set countSent to countSent + 1 send
end tell

I found I had to include a delay after “make new attachment” to give Mail time to encode and add the attachment. Without the delay, Mail gets the send command and sends the message before it adds the attachment.

1 Like