Can't connect to Imap gmail

Topics: Help requests
Jan 6, 2014 at 5:12 PM

I don't know if it is a firewall issue, but I can't connect to imap gmail. Here is the code I am using:
ImapClient client = new ImapClient("",993,true,true);
            client.IsDebug = true;
            result = client.Connect();
  // Do something
The problem is in client.connect() as it always returns false. Here is the exception from the output console - A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll
The thread '<Thread Ended>' (0x2a70) has exited with code 0 (0x0)

Do you have some pointers regarding how can I resolve this issue?

Thanks in advance.
Jan 6, 2014 at 6:23 PM
Edited Jan 6, 2014 at 6:23 PM
Hi imapUser,

first of all, you can reduce your code to:
ImapClient client = new ImapClient("", true);
client.IsDebug = true;

result = client.Connect();
// ..
The port 993 is being selected automatically.

Connecting to GMail works fine, please check your firewall settings.


Jan 6, 2014 at 6:31 PM
Hi Pavel,

I guess thats where I need help - is there any standard firewall settings that I need to do to be able to connect to imap gmail?
Jan 6, 2014 at 6:35 PM
Hi imapUser,

normally no changes are required, however you can check if the firewall didn't block your application.
Have you tried connecting using the sample application on same machine?
Jan 6, 2014 at 6:55 PM
Hi Pavel,

Thanks for the quick reply. I tried the sample app at my home computer and it worked fine. I tried my code at home and it worked fine. Both code and sample app don't work at work computer. Do you suggest any settings I can change to make it to work at work?
Jan 6, 2014 at 7:21 PM
Hi imapUser,

you can try disable the firewall completely, and see if you can connect. If still can't, the issue might be because the port 993 is being blocked in your network and you have to contact the administrator. If the app works fine after disabling the firewall, try open the port 993 and also add the application to exceptions in the firewall.