0
votes

I am writing an applescript which works as an email merge that takes information from a Numbers document (name, email address, license codes, promo codes) and generates an email in Mail. After inserting the base & dynamic content, some text formatting occurs (making text bold and red or blue). The code works, but the message signature disappears once some of the content is edited. The signature is there but it disappears seconds later.

However, if I set a breakpoint (using Script Debugger) on the line the message signature is set, it works just fine. Below is a sample code which illustrates the point:

    tell application "Mail"
        set theMsg to (make new outgoing message with properties {subject:"Test", content:"Wahoo", visible:false})
        tell theMsg
            make new to recipient with properties {name:"Josh Booth", address:"[email protected]"}
            set character 1 to "Y"
            set color of character 1 to {60000, 1, 1}
        end tell
        set theMsg's message signature to signature "JB_SocialMedia"
        log "Fin"
    end tell

Additionally, even though the property visible is set to false, it shows up anyway. Running on OS X Yosemite, but this issue has also happened in Mavericks.

Any thoughts?

1

1 Answers

0
votes

Create the signature with the message.

tell application "Mail"
    set theMsg to (make new outgoing message with properties {subject:"Test", content:"Wahoo", visible:false, message signature:signature "JB_SocialMedia"})
    tell theMsg
        make new to recipient with properties {name:"Josh Booth", address:"[email protected]"}
        set character 1 to "Y"
        set color of character 1 to {60000, 1, 1}
    end tell
    log "Fin"
end tell