1
votes

I'd like to send a mail using a Mac Automator action. I prepared the following mail script:

set recipientName to "<recipient>"
set recipientAddress to "<recipient mail address>"
set theSubject to "<mail subject>"
set textBody to "<text>"

tell application "Mail"
    set theMessage to make new outgoing message with properties {subject:theSubject, content:textBody, visible:true}
    --set recipient
    tell theMessage
        make new to recipient with properties {name:recipientName, address:recipientAddress}
        --send the message
        send
    end tell
end tell

now when I send this it uses the Account that is basically currently selected (highlighted) in the Mail App.

Is there any way to choose a specific account?

1
hey @Dragon5689 how did this go? Did you try my answer below? - adamh

1 Answers

2
votes

You need to set the sender of theMessage to a valid address of one of your accounts.

e.g.

set recipientName to "<recipient>"
set recipientAddress to "<recipient mail address>"
set theSubject to "<mail subject>"
set textBody to "<text>"
set theSender to "[email protected]" -- your valid account email here 

tell application "Mail"
    set theMessage to make new outgoing message with properties {subject:theSubject, content:textBody, visible:true, sender:theSender}
    tell theMessage
        make new to recipient with properties {name:recipientName, address:recipientAddress}
        send
    end tell
end tell