title: Unable to connect to remote server while sending email in asp.net
body: <p>The above error arising while using email sending code my code is</p>
  
  <pre><code>string fromAddress = "mymail";
  string fromPassword = "mypassword";
  var smtp = new System.Net.Mail.SmtpClient();
  smtp.Host = "smtp.gmail.com";
  smtp.Port = 587;
  smtp.EnableSsl = true;
  smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
  smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
  smtp.Timeout = 20000;
  smtp.Send(fromAddress, toAddress, MailSubject, Body);
  </code></pre>
  
  <p>I googled many times but didnt get proper solution.
  Port 587 is enbled and firewall blocking also not there. </p>