[applescripts]

Move messages to named folders

Function:
This script tries to match the address of the sender of an email message to a name in your Address Book, looks for a mailbox with that exact name and then moves the message to this folder. It will not move a message when there is no match to the address or the address matches to more than one contact, for instance when John and Jane Smith share an email account and you have both of them in your Address Book as seperate contacts. It will move the message to the first folder matching the contacts name, there is no checking for multiple matches there.

Usage:
Select one or more messages in any random mailbox in Mail.app and invoke the script for it to try and move those messages.

Download:
Current version, 20040518

Installation:
Save this script to ~/Library/Scripts/Mail Scripts/ for it to appear when you are using Mail.app. If you want to bind a hotkey to the execution of this script, for instance ctrl-m, please add ___ctl-m to the end of the filename. This binding will only work in Mail.app, as far as I know.

This script uses 24U Appearance OSAX 2.1, which is a toolbox for using windows for your script. Without this toolbox, it will not work. The toolbox is free though, you can download it from their website at http://www.24usoftware.com/. Please follow the included instruction for it's respective installation on your system.

Revision history:
20040518: initial public release

Using the code:
Feel free to use this script and continue developing it. I would appreciate a copy of whatever you've developed out of it. And ofcourse, you can stroke my ego by mentioning how inspiring I was when you were writing your script!

Ideas for future development:
There is hardly any error checking and only the most obvious things get checked, so there is much to be done there. Offering a way to (un)check the summary at the end might be a nice feature. This could be done by offering a switch or checkbox in the candystick window. Eventually, I'd love this script to do it's data crunching and then come back with a table view window, in which all messages are listed, with the matches (if any) for the senders and mailboxes found in relation to each message. Ofcourse the user could then select one in case of multiples, with live updating of the table (a different name means other mailboxes). Yeah, that would be nice. Also, maybe this script could be even smarter and match recipients instead of the sender when the sender matches one of the addresses in one of the Accounts of Mail.app ... I use a webmail during the day, in which I move sent messages to the inbox so they download using POP3 when I return home.