With rules in AppleMail you can automatically sort incoming emails into different mailboxes. A user at the ApfelTalk forum had a bit of an exotic problem. He has 600 rules in AppleMail. He must have clicked wrong in one of those and now the rule moves the emails to the trash instead of a mailbox.
Checking 600 rules seemed like a not-so-fun task. So I had a look if I could help with AppleScript. To my astonishment that was possible. Each AppleScriptable app has a dictionary of what you can do with AppleScript. Here is what I can do with rules:
I had everything I needed:
- There is a rule object so that I can get a list of rules.
- The rules have properties for the name and if the rule deletes a message.
With this I was able to make a very simple AppleScript:
tell application "Mail" set theRules to get rules repeat with theRule in theRules set doDelete to delete message of theRule set theName to name of theRule if doDelete then display dialog theName end if end repeat end tell
There is no error handling and the dialog is ugly. But the dialog saved the user at least half an hour of boring work. 600 rules are slightly crazy, though.
I can only imagine that the rules object is there for analysing purposes. Making a nice table with rules, their names and properties doesn't seem too complicated.