2

我要做的是设置一个 Mail.app 规则,将所有 iTunes 收据电子邮件重定向到 Evernote 中的特定笔记本。以下 AppleScript 添加了正确的收件人并修改了主题行,因此我可以包含指向正确 Evernote 笔记本的指针。问题是我无法弄清楚为什么电子邮件的内容会被复制两次。任何帮助表示赞赏。

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

using terms from application "Mail"
on perform mail action with messages theMessages
    repeat with thisMessage in theMessages
        tell application "Mail"
            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"
            delay 1
            -- send newMessage
        end tell
    end repeat
end perform mail action with messages
end using terms from
4

2 回答 2

0

当我尝试转发消息(运行 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
于 2014-02-23T13:17:54.037 回答
0

我已经在 Mac OS X 10.6.8 和 Mail 4.6.1085 以及纯文本电子邮件中尝试过这个。电子邮件的正文一开始并没有在这个设置中重复,但后来我注意到它确实在我的另一个自动回复功能中重复了。这就是发生的事情:

  1. 编写主题为“evernote”的文本电子邮件 2) 下载电子邮件,主题“evernote”触发我的支持电子邮件的自动回复,看起来很正常
  2. 支持自动回复(发送给我自己,因为这是一个测试)触发了印象笔记脚本(下)
  3. 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
于 2013-06-25T08:49:11.650 回答