in my application i m sending a mail from gmail server. when i m executing the code its giving error
here is the 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);
After execution i m getting below error
Message : - "Failure sending mail."
Inner Exception : - {"Unable to connect to the remote server"}
please have a look.