Posts Tagged ‘Sent Items’

Hack of the day: auto-filing IMAP “Sent Items” folder

Wednesday, December 30th, 2009

I file my email in different IMAP folders, grouped by topic rather than the “received messages in one folder, sent in another” model imposed nowadays by most mail clients.  It’s easy to keep the messages I receive organized by topic — when I’m done handling a message, I simply move it into the appropriate folder.

On the other hand, organizing the copies of message I’ve sent is less straightforward.  Visiting my “Sent Items” folder every time I send a message and filing the message I’ve just sent is gross.  What I’ve done in the past is to leave all the copies in “Sent Items” and periodically file all of them one at a time.  This is time-consuming and error-prone, and what’s more, it could be at least partially automated — if I file a message I received in a particular folder, then something ought to be smart enough to figure out that the response I sent should go into the same folder.

After spending over an hour this morning filing “Sent Items” messages, my annoyance threshold was finally exceeded and I decided to automate the process as much as I could.  The result is file-sent-items.pl.  In a nutshell, this script reads each message in your “Sent Items” folder (or whatever it’s called), grabs the message IDs in the “Message-ID”, “Resent-Message-ID”, “In-Reply-To” and/or “References” headers, looks for a message with one of those IDs in your other folders, and if one is found, moves the sent message into its folder.  There’s a bit more too it than that, of course, which you can find out by reading the comment at the top of the script and running it with the “–help” option to get a usage message.

Of course, this script won’t be able to file messages that aren’t part of conversations already filed into other folders, but it still reduces by a lot the amount of filing you have to do by hand.

Share and enjoy!