title: The problem is about sending email in ASP.NET
body: <pre><code>protected void SendEmail(object sender, EventArgs e)
      {
          SmtpClient smtpClient = new SmtpClient();
          MailMessage message = new MailMessage();
          try
          {
              MailAddress fromAddress = new MailAddress("fromemail", "From Me");
              MailAddress toAddress = new MailAddress("toemail", "To You");
              message.From = fromAddress;
              message.To.Add(toAddress);
              message.Subject = "Testing!";
              message.Body = "This is the body of a sample message";
              smtpClient.Host = "smtp.host.com";
              smtpClient.Credentials = new System.Net.NetworkCredential("username", "password");
              smtpClient.EnableSsl = true;
              smtpClient.Port = 587;
              smtpClient.Send(message);
              statusLabel.Text = "Email sent.";
          }
          catch (Exception ex)
          {
              statusLabel.Text = "Coudn't send the message!\n"+ex.Message;
          }
      }
  </code></pre>
  
  <p>The error is</p>
  
  <blockquote>
    <p>"Failure sending mail."</p>
  </blockquote>
  
  <p>I can not send any.
  What is the problem?</p>
  
  <p>innerexception is</p>
  
  <p>System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 74.125.39.109:587 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket&amp; socket, IPAddress&amp; address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception&amp; exception) --- End of inner exception stack trace --- at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress&amp; address, Socket&amp; abortSocket, Socket&amp; abortSocket6, Int32 timeout) at System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback) at System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port) at System.Net.Mail.SmtpClient.GetConnection() at System.Net.Mail.SmtpClient.Send(MailMessage message)</p>