【问题标题】:While redirecting email with AppleScript the content of the email is duplicating. Why?使用 AppleScript 重定向电子邮件时,电子邮件的内容会重复。为什么?
【发布时间】:2013-04-03 02:47:05
【问题描述】:

我要做的是设置一个 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

【问题讨论】:

  • 这可能有助于诊断:它发生在 'make new to recipient...' 之后。
  • 是的,我也注意到了,但我不知道为什么会发生这种情况,或者我的替代方案是什么来实现相同的目标。

标签: applescript


【解决方案1】:

我已经在 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

【讨论】:

    【解决方案2】:

    我在尝试转发消息时遇到了同样的问题(运行 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
    

    【讨论】:

      猜你喜欢
      • 2013-01-18
      • 1970-01-01
      • 2012-10-20
      • 1970-01-01
      • 2019-08-05
      • 1970-01-01
      • 1970-01-01
      • 2017-11-19
      • 1970-01-01
      相关资源
      最近更新 更多