使用AppleScript重定向电子邮件时,电子邮件的内容会重复。为什么?

使用AppleScript重定向电子邮件时,电子邮件的内容会重复。为什么?,applescript,Applescript,我想做的是设置Mail.app规则,将所有iTunes接收电子邮件重定向到Evernote中的特定笔记本。下面的AppleScript添加了正确的收件人并修改了主题行,因此我可以包含指向正确Evernote笔记本的指针。问题是我不明白为什么邮件内容会被复制两次。感谢您的帮助 更新:为了澄清,此脚本作为Mail.app规则的一部分运行。当收到符合规则的电子邮件时,将运行下面的AppleScript。如果您不熟悉Evernote通过电子邮件添加项目的功能,它的工作原理如下:每个Evernote用户都

我想做的是设置Mail.app规则,将所有iTunes接收电子邮件重定向到Evernote中的特定笔记本。下面的AppleScript添加了正确的收件人并修改了主题行,因此我可以包含指向正确Evernote笔记本的指针。问题是我不明白为什么邮件内容会被复制两次。感谢您的帮助

更新:为了澄清,此脚本作为Mail.app规则的一部分运行。当收到符合规则的电子邮件时,将运行下面的AppleScript。如果您不熟悉Evernote通过电子邮件添加项目的功能,它的工作原理如下:每个Evernote用户都会收到一个唯一的电子邮件地址,允许将项目直接添加到他们的Evernote帐户。在主题行中,某些关键字可以添加到将文档直接发送到特定文件夹(@receives)或添加特定标记(#cool)


我已经用MacOSX10.6.8和Mail 4.6.1085以及一封纯文本电子邮件尝试过了。起初,电子邮件的正文文本在这个设置中没有被复制,但后来我注意到它在我的另一个自动回复功能中被复制了。事情是这样的:

  • 编写主题为“evernote”的文本电子邮件2)下载电子邮件, 主题“evernote”触发我的支持电子邮件的自动回复, 这看起来很正常
  • 支持自动回复(已发送到) 我自己,因为这是一个测试)触发了evernote脚本(如下)
  • evernote脚本引用了原始消息并插入了副本 同样的信息
  • 我认为您可以通过存储原始文本并在发送消息之前再次设置来解决此问题。以下内容似乎不会发送重复文本的邮件:

    using terms from application "Mail"
        on perform mail action with messages theMessages
            repeat with thisMessage in theMessages
                tell application "Mail"
                    set theText to content of thisMessage
                    set newMessage to redirect thisMessage with opening window
                    tell newMessage
                        set subject of newMessage to "hello"
                        make new to recipient at beginning of to recipients with properties {address:"mine@email.com"}
                        delete bcc recipients
                        delete cc recipients
                    end tell
                    set the sender of newMessage to "me@me.com"
                    set content of newMessage to thisText
                    delay 1
                    -- send newMessage
                end tell
            end repeat
        end perform mail action with messages
    end using terms from
    

    当我尝试转发消息时,我遇到了同样的问题(运行10.6-10.9) 我通过在添加另一个主题之前存储新消息的内容来修复它

    set themessage to forward eachMail with opening window
    set a to content of themessage
    set thesubject to (subject of eachMail) as rich text
        tell themessage
            set subject to thesubject
            repeat with m in mailtos
                make new to recipient at end of to recipients with properties {address:m}
            end repeat
            set content to a
        end tell
    

    这可能有助于诊断:它发生在“对接收者来说是新的…”之后。是的,我也注意到了这一点,但我不明白为什么会发生这种情况,或者我的替代方案是什么来实现相同的目标。
    set themessage to forward eachMail with opening window
    set a to content of themessage
    set thesubject to (subject of eachMail) as rich text
        tell themessage
            set subject to thesubject
            repeat with m in mailtos
                make new to recipient at end of to recipients with properties {address:m}
            end repeat
            set content to a
        end tell