Mail.app in Mac OS 10.7 added an Archive button. Unfortunately, when archiving a message in a Gmail account, instead of simply putting the message into All Mail folder, Mail.app creates a folder called Archive (in Gmail web interface this folder comes up as [Imap]/Archive) and puts the message there. Is there a way to tell Mail to put the archived messages into Gmail's All Mail instead?
Macos – How to stop Mail.app in Lion creating an Archive folder for archiving in Gmail
apple-mailgmailmacososx lion
Related Solutions
If you have Google Labs enabled, you can try out the advanced IMAP controls feature. Among other things, it allows you to define which labels/folders you want to sync.
This might help you with Question One.
Note also, that part of the reason that this is confusing is that Google designed Gmail from the ground up and it's built around labels -- each message can zero, one or many. IMAP is built on hierarchical folder -- each message is in one.
When Google added IMAP support to Gmail, they had to find a way to graft labels onto IMAP's folder protocol. This article in Gmail help has a nice table showing how IMAP actions map to actions you would perform in the Gmail web interface.
Some more generic information for those getting to this question because of its title:
Gmail is very special when it comes to IMAP. Gmail uses labels, not folders, and there is simply no one-to-one mapping to IMAP. For example: putting a message in the Trash actually kind of assigns the label "Deleted". When labeled as such, any other label for that same message no longer applies.
Be sure to understand the implications of this. Like if you think you copied a message to some IMAP folder, then actually Gmail will only have assigned an additional label to the very same message. Now, if you've (wrongly) set up Mail to move deleted messages to the Trash, then after "deletion" of either of the two occurrences of that single message, the other is removed as well.
To get the full picture when using IMAP for Gmail, I think one should unfortunately at least read all of the following from Google's help:
Recommended IMAP client settings (be sure not to save deleted messages to the Trash)
Even some more details:
Like also noted in the question and other answers: see Google Labs Advanced IMAP Controls, which allows you to set When a message is deleted from the last visible IMAP folder: Move the message to the Gmail Trash. (Or "Bin" for UK English.)
The Gmail SMTP server automatically moves a copy to your Sent Items. So, when using that server, be sure to set up Mail.app to Use only this server. If you don't, then when Mail falls back to another server, you won't have a copy in your Sent Items.
If you want to use another Sender address, then see Adding a custom 'From' address; if you don't then Gmail will change it into your gmail.com address. For fine tuning see the recent new feature Send mail from another address without "on behalf of".
Changing the Gmail language also changes the names of things like Trash (Bin) and Sent Items. So choose the language before telling Mail about the usage of the mailboxes (using menu Mailbox, Use This Mailbox For).
Be sure to create a backup. If messages are somehow deleted form either your computer or Gmail's servers, then after the first IMAP synchronisation they're removed everywhere. (Or, for non-IMAP accounts: deleting any account also removes all of its messages!) When using Time Machine, then to restore items: first activate Mail and then enter Time Machine. This will give you the galaxy and star field with, instead of the default Finder, the Mail interface. Here you can even restore message from accounts you've deleted altogether.
Best Answer
You could edit
/Users/<username>/Library/Mail/V2/MailData/Accounts.plist
settingArchiveMailboxName
to[Gmail]/All Mail
then restart Mail. This seems to work for me.