I use an applescript to store parts of incoming mails in a database. This script is called via special mail rules. It works perfectly since months with one exception: If the selection in the INBOX contains additionally mails which doesn't fit the criteria of the mail rule, these mails are also passed to the script (which in my eyes is a bug from Apple High Sierra) Therefore, I have to compare the transferred data records with the associated rule myself. Below the test script
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
The associated code from Apple in the Users SyncedRules.plist:
<dict>
<key>CriterionUniqueId</key>
<string>XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXXX</string>
<key>Expression</key>
<string>noreply@email.com</string>
<key>Header</key>
<string>From</string>
<key>Qualifier</key>
<string>EndsWith</string>
</dict>
Problem: I always receive following data values for the rule conditions:
ruleExpr: noreply@email.com
ruleType: 束constant ****tfro損
ruleHeader:
ruleQualifier: 束constant ****rqbw損
The variable "ruleHeader" should actually contain the value "from" but is empty. In addition, the contents of "ruleType" and "ruleQualifier" are also not readable.
The "function library" of the Script editor doesn't help.
There are a lot of hints in the internet to add a new Rule but I didn't find any docs nor tipps to receive the content of a rule condition. Any help is appreciated !