title: SmtpClient - The operation has timed out
body: <p>I am trying to create a small app using C# to send email, but I can't get it to work even using port 587 (GMail) TLS or 465 (GMail SSL). I'm not sure what is causing my problem, should I edit my app.config file? Here is my code:</p>
  
  <pre><code>try
  {
    SmtpClient client = new SmtpClient("smtp.gmail.com", 465);
    client.EnableSsl = true;
    client.Timeout = 10000;
    client.DeliveryMethod = SmtpDeliveryMethod.Network;
    client.UseDefaultCredentials = false;
    client.Credentials = new NetworkCredential("myemailid", "mypwd");
  
    MailMessage msg = new MailMessage();
    msg.To.Add(txtTo.Text);
    msg.From = new MailAddress("myemailid");
    msg.Subject = txtSub.Text;
    msg.Body = txtMsg.Text;
  
    client.Send(msg);
    MessageBox.Show("sent");
  }
  catch (Exception ex) 
  {
      MessageBox.Show(ex.Message);
  }
  </code></pre>