title: How to use SSL in TcpClient class
body: <p>In the .NET framework there is a class <code>TcpClient</code> to retrieve emails from an email server. The <code>TcpClient</code> class has 4 constructors to connect with the server which take at most two parameters. It works fine with those servers which does not use SSL. But gmail or many other email providers use SSL for IMAP.</p>
  
  <p>I can connect with gmail server but can not authenticate with email_id and password.</p>
  
  <p>My code for authenticate user is</p>
  
  <pre><code>public void AuthenticateUser(string username, string password)
  {
      _imapSw.WriteLine("$ LOGIN " + username + " " + password);
      //_imapSw is a object of StreamWriter class
      _imapSw.Flush();
      Response();
  }
  </code></pre>
  
  <p>But this code can not login.</p>
  
  <p>So how can I use the <code>TcpClient</code> class to retrieve emails when I have to use SSL?</p>