Gmail Archiving in Apple’s Mail.app
Update: The developer of Archive emailed me to mention that you can easily pass [Gmail]/All Mail directly into defaults write by using the -string flag.
To get running:
- Quit Mail.
- Download and install the Archive plugin.
- Run:
defaults write com.apple.mail ArchiveMailboxName -string "[Gmail]/All Mail"
- Open Mail and start archiving.
This approach is obviously much easier than my previous approach.
Original, outdated post:
Please note: I’m running 10.6.4 and Apple Mail 4.3.
I’ve been using Mail.app for my hosted Google App accounts for a while now and although it works okay, I’ve been really wanting an easy way to Archive email. I want to hit a keyboard shortcut or a button and have my emails moved to Gmail’s All Mail folder.
After searching for a while, I finally came across a great plugin, Archive, a button for Apple Mail, that adds a menu item, keyboard shortcut and toolbar button to archive the selected messages. By default it will move the messages to a folder called Archive. With a regular IMAP account this would be fine, but when you’re using Gmail or Google App accounts, you want the messages moved to [Gmail]/All Mail.
The Archive plugin has a defaults write com.apple.mail ArchiveMailboxName preference that you can override, but there are all sorts of problems when trying to write “[Gmail]/All Mail” to it.
To get around this, I put together a quick shell script that writes “[Gmail]/All Mail” to a temporary file and passes that file into echo which is passed through xargs into defaults write. It shouldn’t be this hard, but it is.
How to get running:
- Quit Mail.
- Download and install the Archive plugin.
- Download my script http://cl.ly/1da2d54afbbcba3abed3.
- Make sure the configure_archive script is executable:
chmod +x configure_archive.sh
- Run it:
./configure_archive.sh
- Open Mail and start archiving.
Here’s the shell script:
#!/bin/bash
echo "[Gmail]/All Mail" > /tmp/archive_mail_plugin_config
archive_mail_plugin_config=`cat /tmp/archive_mail_plugin_config`
echo \'$archive_mail_plugin_config\' | xargs -0 defaults write com.apple.mail ArchiveMailboxName
rm /tmp/archive_mail_plugin_config
