MsgFiler for Apple Mail

I can’t believe that I’ve only just discovered MsgFiler, a Mail plugin for filing messages (duh) that works exactly the way I want. It makes Mail much more useful and keeps me from pining for mutt.1

It’s become fashionable in recent years to just archive your old mail in a single mailbox—or at most a small handful of mailboxes—and use search to dig up old messages if and when they’re needed. Tools like Mail Act-On work very well for this setup. Unfortunately, I can’t use this sort of simplified organization scheme at work.

I’m often required, for legal reasons, to produce a document containing every bit of email correspondence on a particular work project. Since there’s no way to ensure a unique identifier in every message, I can’t use search to generate the document. I have to file the messages in unique mailboxes, one for every project. I have a Mail folder named “[Active projects]” (the brackets are to keep it at the top of the sorted list) with all the individual project mailboxes in it.

Since I have, at any given time, one or two dozen active projects, the single-keystroke style of filing used by Mail Act-On doesn’t work for me. I’d never be able to remember which keystroke goes with which mailbox.

(Since every work project has a unique project number, I suppose I could assign that number as a Spotlight keyword to every project message and use a single mail archive called Project. But that just doubles the work: first assign the keyword, then archive the message. I’d rather just archive the message in a mailbox specific to that project.)

In my Linux days, I used mutt, which had some pretty nifty shortcuts for saving messages in mbox files in any directory. Combined with bash-style filename completion, this made organizing my mail a breeze. But for all of mutt’s efficiency, I don’t think it’s a good choice for email today, with attachments and HTML formatting so common.

What makes MsgFiler such a treat to use is that it gives Apple Mail the efficiency of mutt. After MsgFiler is installed, Mail gets a new menu item, called “Move with MsgFiler.” Go to the Keyboard Preference Pane and assign that menu item to whatever keystroke combination you find convenient. Adam Tow, MsgFiler’s developer, suggests ⌘9, but you can choose anything. I use ⌃⌥⌘M, which may seem complicated, but is actually very easy to execute, because the ⌃⌥⌘ keys are adjacent and I can mash them down with my left hand without looking.

MsgFiler is invoked with the keystroke combo, and a window pops up for selecting a mailbox. Start typing, and all the mailboxes with names containing that string of characters will appear. The character string can be anywhere in the mailbox name, not just at the beginning.

Select the mailbox you want with the arrow key (or keep typing until there’s only one left), hit Return, and the message will be moved to that mailbox. The next time you invoke MsgFiler, that same mailbox will be preselected for you. This has been a big timesaver for me on days when most of my correspondence has been on a single project.

MsgFiler works with messages selected in any mailbox. Obviously, most of my filing is done from the Inbox, but another common use is to refile my own messages from the Sent mailbox. I’ve found that the best way to keep on top of the refiling is to move my emails to the proper mailbox right after I send them. To help me with this, I’ve written an AppleScript called “Last Sent.”

 1:  tell application "Mail"
 2:    set theViewer to first message viewer
 3:    set sentBox to sent mailbox of theViewer
 4:    set lastSent to first message of sentBox
 5:    get subject of lastSent
 6:    set selected mailboxes of theViewer to {sentBox}
 7:    delay 1
 8:    set selected messages of theViewer to {lastSent}
 9:  end tell
10:  
11:  tell application "System Events" to keystroke "m" using {control down, option down, command down}

When run, Last Sent opens the Sent mailbox, selects the most recent email in it, and invokes MsgFiler. I run it every time I write a project email.

Three notable things about Last Sent:

  1. You’ll note in Line 4, that the most recently sent message, called lastSent, is the first message in the Sent mailbox, not, as you might expect (and as I expected), the last message. Forget it, Jake. It’s AppleScript.
  2. The delay of one second in Line 7 is needed (on my computer, anyway) to give Mail time to switch to the Sent mailbox before doing the selection in Line 8.
  3. The set selected messages to command expects a list, not a single message, which is why lastSent is surrounded by braces.

I call Last Sent using FastScripts with a keystroke combo of ⌃⌥⌘L. In Snow Leopard, you could probably turn it into a Service and assign it a keystroke combo. I confess I haven’t looked into that feature, as I’m familiar with FastScripts and it’s always worked well for me.

With $8 for MsgFiler and a bit of scripting, I now have a GUI mail program with the efficiency of mutt.

Tags:


  1. Pine-ing for mutt,” get it? Unix mail jokes are the best, amirite?