通过Applescript发送电子邮件时发件人不正确

mar*_*nte 5 applescript

下面的Applescript是我用过多年的形式.并且基本上是使用Applescript发送电子邮件的众所周知的方法.

 tell application "Mail"
    set newMessage to make new outgoing message with properties {subject:"IP Address", content:"Your IP Address Is: 86.195.132.134"}
    tell newMessage
        set visible to false
        set sender to "mark@sender.com"
        make new to recipient at end of to recipients with properties {address:"recipient@mac.com"}
        send
    end tell
end tell
Run Code Online (Sandbox Code Playgroud)

我今天刚刚注意到的是脚本中设置的"发件人"电子邮件,如果未选中其帐户邮箱,则可能不是Mail.app使用的电子邮件.如果选择了主收件箱,或者如果选择了单个邮箱,则将使用随机邮箱,然后将使用其帐户中的地址.

我认为这是因为在Mail首选项中,在Composing下.有一个设置为" 发送新邮件:"


在此输入图像描述


你不能选择'否'.唯一的选项是"所选邮箱的帐户"或组合框下拉列表中的一个电子邮件地址.

我必须承认,在我去狮子会之前,我不知道这是否发生过.

有没有人知道这个的修复,或者这是一个已知的错误?

谢谢.

小智 14

这对我来说很有用,希望它有所帮助:

tell application "Mail"
  set theOutMessage to make new outgoing message with properties {visible:true}
  tell theOutMessage
    make new to recipient at end of to recipients with properties {address:"first@mail.com"}
    set sender to "Name Surname <name.surname@mail.com>"
    set subject to "Message Subject"
    set content to "Message Text"
  end tell
end tell
Run Code Online (Sandbox Code Playgroud)