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

发布于 2025-01-07 07:10:44 字数 1080 浏览 0 评论 0原文

下面的 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 "[email protected]"
        make new to recipient at end of to recipients with properties {address:"[email protected]"}
        send
    end tell
end tell

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

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


在此处输入图像描述


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

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

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

谢谢。

The Applescript below is in the form that I have used for a number of years. And is basically a well known method of sending emails using 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 "[email protected]"
        make new to recipient at end of to recipients with properties {address:"[email protected]"}
        send
    end tell
end tell

What I just noticed today is the 'sender' email set in the script, may not be the one Mail.app
uses if its account mail box is not selected. A random one will be used if the main inbox is selected or if an individual mailbox is selected then an address from it's account will be used.

I think this is because in the Mail preferences, under Composing. There is a setting to 'Send new messages from:'


enter image description here


You cannot select 'NO'. The only options are 'Account of selected mailbox' or one of the email addresses that are in the combo box drop down.

I must admit I do not know if this was been happening before I went to Lion.

Does anyone know of a fix for this, or if this is a known bug??.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

第七度阳光i 2025-01-14 07:10:44

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

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:"[email protected]"}
    set sender to "Name Surname <[email protected]>"
    set subject to "Message Subject"
    set content to "Message Text"
  end tell
end tell

this worked for me just now, hope it helps:

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:"[email protected]"}
    set sender to "Name Surname <[email protected]>"
    set subject to "Message Subject"
    set content to "Message Text"
  end tell
end tell
能怎样 2025-01-14 07:10:44

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

full name <email_address>

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

set emailSender to "FirstName LastName <[email protected]>"

I don't know where I got this from, but the sender needs a particular format. It should be:

full name <email_address>

You look in Mail's account preferences, and use the "Full Name" and "email address" fields from one of the accounts... but put it in the form I showed. I just checked and this format works for me. As such I use this in my applescripts...

set emailSender to "FirstName LastName <[email protected]>"
荒路情人 2025-01-14 07:10:44

要了解您有哪些可用电子邮件,这可以帮助您:

tell application "Mail"
    set emailList to {}
    -- note, if the following line throws an error, you can probably remove "where enabled is true" if you don't have disabled accounts.
    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

To figure out what emails you have available this can help:

tell application "Mail"
    set emailList to {}
    -- note, if the following line throws an error, you can probably remove "where enabled is true" if you don't have disabled accounts.
    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
小ぇ时光︴ 2025-01-14 07:10:44

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

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

If you are looking for a script that will send an email, this one should work.

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文