Gmail Integration

Mar 30, 2011 at 3:09 PM

Is there any Gmail integration documentation? Just wondering what settings are required for Gmail. Any help is appreciated (conenction, downloading attachments and archiving)

Mar 30, 2011 at 6:34 PM

Well, Gmail behaves like any other IMAP service, the only speciality is that Google dropped all but one authentication method.

The only one left is XOAUTH and although the Docu is still under construction your in luck the XOAuth section is already online.

If you take a look at the demo, you will will find a 3-legged implementation already included.

Hope this helps


Mar 30, 2011 at 6:55 PM

Thanks, I will take a look.

Mar 30, 2011 at 9:24 PM

I don't exactly understand, what's the matter, but today I have forced ImapClient to login to Gmail with the the LOGIN mechanic, and this attempt was successfull.

Mar 30, 2011 at 10:31 PM
Edited Mar 30, 2011 at 10:41 PM

I have to admit I haven't tried to enforce any login mechanics yet, it is of course possible to ignore the servers capability advertisement all together and just send the PLAIN or LOGN authentification.

If I however check the Gmail server capabilities AUTH=PLAIN or AUTH=LOGIN are not among them, but if it works, all the better.

Jan 9, 2012 at 11:31 PM

Can someone please send en example of how to login to GMail? The library looks really good but if it doesn't integrate with the most popular imap service it's no use :(

Jan 9, 2012 at 11:34 PM

The example includes this line:


which is unacceptable for a service app. Other IMAP libraries are somehow able to connect with plain login/password.


Jan 10, 2012 at 6:11 PM
Edited Jan 10, 2012 at 6:13 PM

Ok it works for me with this code (v0.4):


private readonly ImapClient _client;


_client = new ImapClient();
_client.Security = SecurityPolicies.Explicit;
_client.Connect("", 993);
_client.ManualSaslAuthenticationRequired += _client_ManualSaslAuthenticationRequired;
bool ok = _client.Authenticate("", "");


void _client_ManualSaslAuthenticationRequired(object sender, ManualSaslAuthenticationRequiredEventArgs e)
  var cmd = new ImapCommand(string.Format("LOGIN \"{0}\" \"{1}\"", "", "password"));
  ImapResponseReader rdr = e.Client.SendAndReceive(cmd);
  e.IsAuthenticated = rdr.IsOk;
Jan 10, 2012 at 10:41 PM

Hey, there is no need to do this by yourself, the regular Login mechanism is already implemented.

var success = _client.Authenticate("username", "password", SaslMechanics.Login);

The above code will log you in to your GMail account.