【问题标题】:Incorrect sender when sending Email via Applescript通过 Applescript 发送电子邮件时发件人不正确
【发布时间】:2012-03-10 08:13:06
【问题描述】:

下面的 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

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

我认为这是因为在邮件首选项中的撰写下。有一个设置可以“从以下位置发送新消息:”



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

我必须承认,在我去 Lion 之前,我不知道这是否发生过。

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

谢谢。

【问题讨论】:

    标签: applescript


    【解决方案1】:

    这刚刚对我有用,希望对您有所帮助:

    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
    

    【讨论】:

    • 您好,感谢您的回答。您会看到第一个答案已经暗示了这一点。当时它在 Lion 上不起作用。我现在在 ML 上。是的,这种格式或仅使用电子邮件地址方法现在似乎又可以使用了。所以这个错误似乎是固定的。我已将您的答案标记为已接受。既然它让我再看一遍,这个问题就可以结束了。
    • 只是补充一点,至少在 Mavericks 中,发件人电子邮件地址必须附加到 Mail 中的至少一个帐户。否则它会回到 Mail 的默认值。
    • 仅使用 Yosemite (10.10) 中的电子邮件地址不起作用。它需要全名和电子邮件地址格式。
    【解决方案2】:

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

    full name <email_address>
    

    您查看 Mail 的帐户首选项,并使用其中一个帐户的“全名”和“电子邮件地址”字段......但将其放入我显示的表格中。我刚刚检查过,这种格式对我有用。因此,我在我的 applescripts 中使用它...

    set emailSender to "FirstName LastName <hank@sender.com>"
    

    【讨论】:

    • 嗨@regulus6633,好久没说话了。希望你好。将发件人设置为“全名 ”,在选择收件箱和与该地址不关联的单个邮箱时给出相同的结果。
    • 嗨,马克,很久了。其实我现在病了,但除此之外做得很好。无论如何,你是对的。这对我也不起作用。当我测试它时,巧合的是,我使用的帐户恰好是选择的一封邮件。经过进一步测试,它不起作用,我不知道为什么。如果我想到什么我会回来的。
    • 希望你早日康复。感谢您的关注。我也会这样做..干杯
    • 这适用于优胜美地 (10.10)。如果一个人有多个地址,则省略全名可能会导致发件人不正确。
    【解决方案3】:

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

    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
    

    【讨论】:

    • 感谢您尝试提供帮助,但显然您没有阅读或理解该问题。这不是一个有效的答案。您的脚本与我给出的示例或解决我的问题没有任何不同。
    【解决方案4】:

    要弄清楚您有哪些可用的电子邮件,这会有所帮助:

    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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-07-01
      • 1970-01-01
      • 2011-08-21
      • 2016-03-10
      • 1970-01-01
      • 2015-10-22
      • 2010-10-16
      • 1970-01-01
      相关资源
      最近更新 更多