Make sure TLS/SSL is enabled in AM's gmail settings.
Also, you need to enable IMAP from within gmail's web interface before you can use IMAP in an email client.
Lastly, make sure your gmail username and password are correct.
I say that one or both of the first two suggestions are more likely than the third, but it pays to double-check.