Click here to Skip to main content
15,887,812 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When I want to connect the imap.gmail.com with ssl, It did not work in sslStream.AuthenticateAsClient("imap.gmail.com") , The program stop here.

Here is my code:

C#
var m_oImapServ = new TcpClient("imap.gmail.com", "995");

var sslStrm = new SslStream(m_oImapServ.GetStream(),false);                    

    sslStrm.ReadTimeout = 30000;
    try
        {
            ((SslStream)sslStrm).AuthenticateAsClient("imap.gmail.com");

         }
     catch (AuthenticationException e)
          {
             Console.WriteLine("Exception: {0}", e.Message);
             if (e.InnerException != null)
                 {
                    Console.WriteLine("Inner exception: {0}", e.InnerException.Message);
                  }
                   Console.WriteLine("Authentication failed - closing the connection.");
                   m_oImapServ.Close();
                   return ImapResponseEnum.IMAP_FAILURE_RESPONSE;
                  }  

      m_oNetStrm = (Stream) sslStrm;
     m_oRdStrm = new StreamReader(sslStrm);


As client side need a cetification? Can anybody help me? thanks a lot.
Posted

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900