[英]choosing mail account in applescript
I'd like to send a mail using a Mac Automator action. 我想使用Mac Automator操作发送邮件。 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? 有什么办法可以选择一个特定的帐户?
You need to set the sender
of theMessage to a valid address of one of your accounts. 您需要将Message的
sender
设置为您的帐户之一的有效地址。
eg 例如
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.