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

通过Applescript发送电子邮件时发件人不正确,applescript,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"}

下面的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
我今天注意到的是脚本中设置的“发件人”电子邮件,可能不是one Mail.app 如果未选择其帐户邮箱,则使用。如果选择了主收件箱或单个邮箱,则将使用随机邮箱,然后将使用其帐户中的地址

我认为这是因为在邮件首选项中,在组合下。有一个“从以下位置发送新邮件”的设置:



您不能选择“否”。唯一的选项是“选定邮箱的帐户”或组合框下拉列表中的一个电子邮件地址

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

有没有人知道这个问题的解决方法,或者这是一个已知的bug


谢谢。

我不知道这是从哪里得到的,但是发件人需要一种特殊的格式。应该是:

full name <email_address>
全名
您可以查看Mail的帐户首选项,并使用其中一个帐户的“全名”和“电子邮件地址”字段。。。但是把它放在我展示的表格里。我刚检查过,这个格式适合我。因此,我在我的应用程序描述中使用这个

set emailSender to "FirstName LastName <hank@sender.com>"
将emailSender设置为“FirstName LastName”

如果您正在寻找一个可以发送电子邮件的脚本,这个脚本应该可以工作

set theRecipient to text returned of (display dialog "Who would you like to email" default answer "" buttons {"Cancel", "Ok"} default button 2)
set theSubject to text returned of (display dialog "What is the subject" default answer "" buttons {"Cancel", "Ok"} default button 2)
set theContent to text returned of (display dialog "What would you like to say" default answer "" buttons {"Cancel", "Ok"} default button 2)
tell application "Mail"
    set theNewMessage to make new outgoing message with properties {subject:theSubject, content:theContent, visible:true}
    tell theNewMessage
        make new to recipient at end of to recipients with properties {address:theRecipient}
        send
        tell application "Mail"
            activate
        end tell
    end tell
end tell

这对我来说很有效,希望能有所帮助:

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
告诉应用程序“邮件”
设置OutMessage以使新的传出消息具有属性{visible:true}
告诉我们消息
在结尾处向收件人添加新的收件人,并向具有属性{地址:}的收件人添加新的收件人first@mail.com"}
将发件人设置为“姓名”
将主题设置为“消息主题”
将内容设置为“消息文本”
结束语
结束语

要了解您有哪些可用的电子邮件,请执行以下操作:

tell application "Mail"
    set emailList to []
    repeat with theAccount in (every account where enabled is true)
        tell theAccount
            set accountEmails to email addresses
            set accountFullName to full name
            repeat with accountEmail in accountEmails
                set fullEmail to accountFullName & " <" & accountEmail & ">"
                set emailList to emailList & fullEmail
            end repeat
        end tell
    end repeat
end tell

get emailList
告诉应用程序“邮件”
将emailList设置为[]
对中的帐户重复此操作(启用的每个帐户均为true)
报账
将accountEmails设置为电子邮件地址
将accountFullName设置为全名
在accountEmails中重复accountEmail
将fullEmail设置为accountFullName&“”
将emailList设置为emailList和fullEmail
结束重复
结束语
结束重复
结束语
获取电子邮件列表

Hi@regulus6633,好久不说话了。祝你一切顺利。将发件人设置为“全名”,将给出与所选收件箱相同的结果,并且单个邮箱与该地址不关联。您好,是,时间很长。事实上我现在病了,但在其他方面做得很好。无论如何,你是对的。这对我也不管用。当我测试它时,巧合的是,我使用的帐户恰好是邮件选择的帐户。经过进一步测试,它不起作用,我不知道为什么。如果我想点什么,我会回来的。希望你早日康复。谢谢你的关注。我也会这么做。。欢呼这部作品在约塞米蒂(10.10)。如果一个人有多个地址,省略全名可能会导致错误的发件人。感谢您的帮助,但显然您没有阅读或理解问题。这不是一个有效的答案。您的脚本与我给出的示例或解决我的问题没有任何不同。您好,谢谢您的回答。您将看到,第一个答案之一已经提出了这一点。这在当时的Lion上是不起作用的。我现在在ML上。是的,这种格式或者仅仅使用电子邮件地址的方法现在似乎又起作用了。因此,这个bug似乎已经被修复了。我已把你的回答标为已接受。因为它让我再看一次,这个问题可以结束了。只是要补充一点,至少在Mavericks中,发件人的电子邮件地址必须附加到邮件中的至少一个帐户。否则,它将返回到邮件的默认值。仅使用约塞米蒂(10.10)中的电子邮件地址不起作用。它需要全名和电子邮件地址格式。