Tuesday, January 01, 2008

Mail.app 3.x in Leopard - Rule to Tag Mail as "Expiring" Takes Advantage of Address Book Groups

As a New Year's project, besides biking a lot up and down along the Sakai River on my new Centurion, I decided to try switching from Entourage 2004 and its monolithic mail store file, to the Mail.app that comes with OS/X Leopard and use Gmail IMAP. One thing I have set up in Entourage is a rule that runs an AppleScript to search a long list of sender email addresses from which comes mail I want to mark as "Expiring". These are newsletters, RSS newsfeed updates and other information that I don't necessarily want to keep, but want an easy way to find for later deletion.

Mail.app's rules work fine, but, once you get past 10 or 15 criteria lines inside a given rule, you cannot add more because the panel being used does not scroll as you can see here. I was going to rewrite my original Entourage script that I was triggering for every message:

tell application "Microsoft Entourage"
   
    set theMsg to item 1 of (get current messages)
    set theAddress to the sender of theMsg
    set theAddressString to the address of theAddress
    set theName to the display name of theAddress
    set theSubject to the subject of theMsg
    set theTargetCategory to category "Expiring"
   
    --List of mail addresses to check
    set fromList to {"postmaster@somedomain.com", "news@bigcorp.com", "announcement@garageco.com"}
   
    if fromList contains theAddressString then
        set category of theMsg to theTargetCategory
    end if
end tell

... and try to use this method for all mail that comes in and is processed by Mail.app. However, it occurred to me that I could simply add all senders to my address book, put the ones I want to mark as Expiring in an Address Book group, then run a rule to check that.

Turns out that Address Book is indeed well integrated and there are rules you can use. In addition, to have the ability in Mail.app to "tag" messages like you can do already in Entourage 2004 via its Categories, the excellent MailTags comes to the rescue, so that you can keyword each message you are marking.

Here are the steps:
  • In Address Book, add a group, say, "Expiring".
  • In MailTags preferences in Mail Preferences, add the keyword "Expiring".
  • In Mail.app, open Mail preferences and open the Rules pane. Add a new rule and give it a name like Expires.
  • If "Any" of the conditions is met, choose "Sender is a Member of Group" and the group name "Expiring".
  • Perform the following actions: choose "Set color of message" "of background" or "of text" and a color to indicate that the message is Expiring.
  • Next action: "Set mailtags keyword" then "Add" then "Expiring".
  • Next action: "Stop Evaluating Rules" if appropriate.
  • Save and test.

Because you have the keyword "Expiring" now in the headers of messages that trigger this rule, you can use a smart folder in Mail.app to view all expiring messages and make a human decision on what action to take - delete or archive.

2 comments:

Randy said...

Funny, I resolved to do the exact same thing yesterday. So far, so good. Now, I'm trying to decide how to sync Mail on iPhone too.

Rick Cogley said...

Hi Randy - thanks for visiting. Did you resolve to cycle up and down the Sakai river, or, to tag your mail? :-)

Note, MailTags does not work with GMail, the last time I checked. Google's IMAP implementation is a little different, with the "All Mail" folder they have, and the maker of MailTags was not able to get a workaround that would allow the tags to survive all the various manipulations a mail message goes thru when it hits Gmail. With normal IMAP mail, it works fine. I think MobileMe for example works fine.

Regards, and happy new year,
Rick