title: Reading mails from gmail account in asp.net
body: <p>i want to read the mails from gmail account.. i tried to login.. and was successfull.. but unable to get the mails from the inbox..
  below is the code i used for logging in...</p>
  
  <pre><code>try
          {
  
              TcpClient tcpclient = new TcpClient(); // create an instance of TcpClient
              tcpclient.Connect("pop.gmail.com", 995); // HOST NAME POP SERVER and gmail uses port number 995 for POP 
              System.Net.Security.SslStream sslstream = new SslStream(tcpclient.GetStream()); // This is Secure Stream // opened the connection between client and POP Server
              sslstream.AuthenticateAsClient("pop.gmail.com"); // authenticate as client 
              //bool flag = sslstream.IsAuthenticated; // check flag 
              System.IO.StreamWriter sw = new StreamWriter(sslstream); // Asssigned the writer to stream
              System.IO.StreamReader reader = new StreamReader(sslstream); // Assigned reader to stream
              sw.WriteLine("username@gmail.com"); // refer POP rfc command, there very few around 6-9 command
              sw.Flush(); // sent to server
              sw.WriteLine("password");
              sw.Flush();
              sw.WriteLine("RETR 1"); // this will retrive your first email 
              sw.Flush();
              sw.WriteLine("Quit "); // close the connection
              sw.Flush();
              string str = string.Empty;
              string strTemp = string.Empty;
              while ((strTemp = reader.ReadLine()) != null)
              {
                  if (strTemp == ".") // find the . character in line
                  {
  
                      break;
                  }
  
                  if (strTemp.IndexOf("-ERR") != -1)
                  {
                      break;
                  }
                  str += strTemp;
              }
              Response.Write(str);
              Response.Write("" + "Congratulation.. ....!!! You read your first gmail email ");
          }
          catch (Exception ex)
          {
              Response.Write(ex.Message);
          }
  </code></pre>
  
  <p>can anyone please tell me how can i get the actual mails from the inbox.</p>