I’m a fan of using metadata to classify and file things rather than declarative systems of nested folders. Most of the documents and data that I store for personal use are in DEVONthink which has robust support for metadata. On the email side, there’s MailTags which lets you apply metadata to emails. Since MailTags also supports AppleScript, I began to wonder whether it might be possible to script workflows around email processing. Indeed it is, once you discover the trick of what dictionary to use.
The key is to use
MailTagsHelper for the dictionary. To access the terms from that dictionary, you need to embed the code in the following block:
using terms from application "MailTagsHelper"
Here’s a little script that fulfills a workflow need of mine. I try to assign incoming emails to projects and/or give them keywords right away either manually or via Mail rules. After being tagged I want them out of my Inbox and into a reference folder. This script moves any tagged message or one with a project assigned into the Reference folder after 2 days. You’ll have to modify it to meet your needs and insert your account information.