Over at Hawk Wings, they’ve posted a neat AppleScript to help optimize Mail.app
I ran the command line version yesterday to see if it sped Mail up, and it did.

ell application "Mail" to quit
set sizeBefore to do shell script "ls -lah ~/Library/Mail | grep -E 'Envelope Index$' | awk {'print $5'}"
do shell script "/usr/bin/sqlite3 ~/Library/Mail/'Envelope Index' vacuum"
set sizeAfter to do shell script "ls -lah ~/Library/Mail | grep -E 'Envelope Index$' | awk {'print $5'}"
display dialog ("Mail index before: " & sizeBefore & return & "Mail index after: " & sizeAfter & return & return & "Enjoy the new speed!")
tell application "Mail" to activate

If you save the above code down as an AppleScript, you can then call that file in an iCal alert. I’ve set one up to run monthly to keep Mail perky and running smooth.