繁体   English   中英

通过Mavericks中的邮件规则处理Applescript中的传入消息

[英]Processing incoming messages in Applescript via mail rule in Mavericks

我有一个简单的自动回复脚本,该脚本基于我在此处和其他地方看到的示例,旨在从垃圾邮件过滤邮件规则运行。 这是要点:

on perform_mail_action(theData)
    tell application "Mail"
        set theMessages to |selectedMessages| of theData
        repeat with theIncomingMessage in theMessages
            set theOriginalSender to sender of theIncomingMessage
            set theOriginalSubject to subject of theIncomingMessage
            set theOriginalContent to content of theIncomingMessage
            set t to ""
            set t to t & "This is an automated response to your message below..."
            set t to t & return & return & "===============================================" & return & return
            set t to t & "Subject:" & theOriginalSubject & return & return & theOriginalContent
            set theReply to make new outgoing message
            tell theReply
                make new to recipient at beginning of to recipients ¬
                    with properties {address:theOriginalSender}
                set sender to "xxx@xxx.net"
                set subject to "RE: your message"
                set content to t
                send
            end tell
            set mailbox of theIncomingMessage to mailbox "Trash"
        end repeat
    end tell
end perform_mail_action

我知道调用此脚本的规则正在触发,因为它会发出声音。 但是什么也没发送,传入的消息仍保留在我的收件箱中。

如果我删除第一行和最后一行,然后用

set theMessages to messages of mailbox "test" of account "iCloud"

然后它将成功处理“测试”文件夹中的所有消息(它发送答复并删除传入的消息)。

该规则不执行任何操作,只播放声音并调用脚本。 如上所述,声音在播放。 我想念什么?

将前3行(包括set theMessage... )替换为:

using terms from application "Mail"
   on perform mail action with messages theMessages for rule theRule
      tell application "Mail"

将最后一行替换为:

   end perform mail action with messages
end using terms from

为了详细说明Michele Percich的回复,尽管在线上有可用信息(例如Scripting Mail简介 ),Mail似乎也没有运行以下形式的处理程序:

on perform_mail_action(theData)

但是,如果以这种形式编写,它将运行处理程序:

using terms from application "Mail"
   on perform mail action with messages theSelectedMessages for rule theRule

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM