从Applescript的邮件规则获取消息 [英] Getting at a Message from a Mail Rule in Applescript

查看:122
本文介绍了从Applescript的邮件规则获取消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为学习Applescipt的借口,我编写了一个脚本,该脚本将附加到邮件规则中以过滤邮件.我四处寻找并整理了这么多代码:

As an excuse to learn Applescipt, I writing a script to be attached to a Mail rule to filter messages. I scrounged around and put together this much code:

on perform_mail_action(theData)
    tell application "Mail"
        set theSelectedMessages to |SelectedMessages| of theData
        set theRule to |Rule| of theData
        repeat with a from 1 to count theSelectedMessages
            set theMessages to selection
            set theMessage to item 1 of theMessages
        end repeat
    end tell
end perform_mail_action

我本以为该规则只会传递一条消息,但您永远不会知道,因此重复是有意义的.我假设选择"是指向SelectedMessages中某个项目的指针.似乎很奇怪的是将Message设置为Messages的项目1".我本以为您会编写代码将theMessage设置为selection".我想了解邮件的内容",以测试某些单词.

I would have thought the rule would only pass one message, but you never know so the repeat makes sense. I presume "selection" is a pointer to an item in theSelectedMessages. What seems strange is "set theMessage to item 1 of theMessages". I would have thought you would code "set theMessage to selection". I want to get to the body, "content" of the message to test for certain words.

感谢您的帮助,腐烂

推荐答案

/Library/Scripts/Mail Scripts/Rule Actions/Sample Rule Action Script.scpt 中有一个示例规则脚本.您将需要使用Mail的脚本字典中设置的处理程序声明,即

There is an example rule script at /Library/Scripts/Mail Scripts/Rule Actions/Sample Rule Action Script.scpt. You will need to use the handler declaration that is set in Mail's scripting dictionary, i.e.

on perform mail action with messages theMessages for rule theRule

这篇关于从Applescript的邮件规则获取消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆