在AppleScript中选择邮件帐户

时间:2014-07-23 08:25:59

标签: macos email applescript

我想使用Mac Automator动作发送邮件。我准备了以下邮件脚本:

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

现在当我发送它时,它使用邮件应用程序中基本上当前选中(突出显示)的帐户。

有没有办法选择特定帐户?

1 个答案:

答案 0 :(得分:2)

您需要将消息的sender设置为其中一个帐户的有效地址。

e.g。

set recipientName to "<recipient>"
set recipientAddress to "<recipient mail address>"
set theSubject to "<mail subject>"
set textBody to "<text>"
set theSender to "dragon5689@stackoverflow.com" -- 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