使用Applescript接收规则条件电子邮件

问题描述 投票:0回答:1

我使用applescript将部分传入邮件存储在数据库中。通过特殊的邮件规则调用此脚本。自几个月以来,它完美运行,但有一个例外:如果“收件箱”中的选择还包含其他不符合邮件规则标准的邮件,则这些邮件也会传递给脚本(在我看来,这是Apple High Sierra的一个错误)因此,我必须自己比较传输的数据记录和关联的规则。测试脚本下方

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

                set ruleName to name of theRule
                set ruleScriptName to name of me

                repeat with theCondition in rule conditions of theRule

                    set {expression:ruleExpr, header:ruleHeader, rule type:ruleType, qualifier:ruleQualifier} to theCondition
                    log ...
                end repeat
            end tell
        end perform mail action with messages
    end using terms from

Apple的用户SyncedRules.plist中的关联代码:

<dict>
    <key>CriterionUniqueId</key>
    <string>XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXXX</string>
    <key>Expression</key>
    <string>[email protected]</string>
    <key>Header</key>
    <string>From</string>
    <key>Qualifier</key>
    <string>EndsWith</string>
</dict>

问题:对于规则条件,我总是收到以下数据值:

ruleExpr: [email protected]
ruleType: 束constant ****tfro損
ruleHeader:
ruleQualifier: 束constant ****rqbw損

变量“ ruleHeader”实际上应包含值“ from”,但为空。另外,“ ruleType”和“ ruleQualifier”的内容也不可读。

脚本编辑器的“功能库”无济于事。

[Internet上有很多提示来添加新规则,但是我没有找到任何文档或提示来接收规则条件的内容。任何帮助表示赞赏!

email applescript conditional-statements rules
1个回答
0
投票

这是我的问题的“ ruleHeader”部分的解决方案:

            ...
                #set {expression:ruleExpr, header:ruleHeader, rule type:ruleType, qualifier:ruleQualifier} to theCondition

                tell theCondition
                    set ruleExpr to the expression
                    set ruleHeader to the header key
                    set ruleType to the rule type
                    set ruleQualifier to the qualifier
                end tell
            ...

返回参数的结果现在是正确的:

Type: 束constant ****tfro損
Header: 束constant erutthdk損
Qualifier: 束constant ****rqew損

要分离值(类型常量),我用

set commandType to rich text 15 thru 18 of (ruleType as string)
set commandHeader to rich text 11 thru 18 of (ruleHeader as string) 
set commandQualifier to rich text 15 thru 18 of (ruleQualifier as string)

并获得

commandType: tfro
commandHeader: erutthdk
commandQualifier: rqew

您可以在这里找到这些常量的解释:http://ftp.icm.edu.pl/packages/Hacked%20Team.git/core-macos/core/RCSNativeMail.h

© www.soinside.com 2019 - 2024. All rights reserved.