Send Mail from ASP.NET
<p>in my application i m sending a mail from gmail server. when i m executing the code its giving error</p>

<p>here is the code</p>

<pre><code>    mail.To.Add(txtTo.Text);
    mail.From = new MailAddress(txtFrom.Text);
    mail.Subject = txtSubject.Text;
    mail.Body = txtBody.Text;
    mail.IsBodyHtml = true;
    if (FileUpload1.HasFile)
    {
          mail.Attachments.Add(new Attachment(FileUpload1.PostedFile.InputStream,        FileUpload1.FileName));
    }
     SmtpClient smtp = new SmtpClient();
     smtp.Host = "smtp.gmail.com"; 
     smtp.Port = 587;
     smtp.UseDefaultCredentials = false;

     smtp.Credentials = new System.Net.NetworkCredential
         ("my gmail ID", "my password");

    smtp.EnableSsl = true;
    smtp.Send(mail);
</code></pre>

<p>After execution i m getting below error</p>

<pre><code>    Message : -  "Failure sending mail."
   Inner Exception : - {"Unable to connect to the remote server"}   
</code></pre>

<p>please have a look.</p>
