exception thrown on connection "dont connect"

Jul 13, 2013 at 2:38 PM
I am getting a ImapException thrown with a message of "don't connect" on the following code. What am I doing wrong? The dev environment is VS2012 and have tried with both .net 4 and .net 4.5.
static void Main(string[] args)
 {
            int port = 993;
            string host = "imap.google.com";

            try
            {
                ImapClient c = new ImapClient(host, port, true);
                c.IsDebug = true;
                bool state = c.Connection();
                
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            
}           
Jul 13, 2013 at 3:05 PM
aha. I found the error the host should be imap.gmail.com, and not imap.google.com. You might want to make note of that.
Coordinator
Jul 13, 2013 at 7:33 PM
Hi hank6764,

Thank you for your message! This error occurs if the connection to the host cannot be established, which can be caused by wrong host name, server unavailability etc. The library isn't only targeting GMail, so I'm not sure if it's required to note the connection settings for it anywhere. Actually the correct settings for GMail are displayed by default in the sample application provided.


Best regards,

Pavel Azanov
Sep 5, 2013 at 1:47 PM
Hi ;
i have same problem any one help me plase ?
       ImapX.ImapClient client = new ImapX.ImapClient("imap.gmail.com", 993, true);
            bool result = client.Connection();
error is "dont connect"
Coordinator
Sep 5, 2013 at 4:49 PM
Hi HasanGundogdu,

first of all, can you check if you can access your GMail account on same machine through browser and it doesn't ask you for captcha or any other security checks?

If it is all fine, please set IsDebug on your ImapClient to true, and post here the console output. All server responses will be logged there.


Best regards,

Pavel Azanov
Sep 6, 2013 at 9:04 AM
thanks for reply pavel_azanov and i am sorry for my bad english :)
i think problem are ports
i think port is closed
Coordinator
Sep 6, 2013 at 9:22 AM
Hi HasanGundogdu,

yes, that's another point, always check your firewall configuration too, that's fastest reason for this exception to occur.