my code
protected void btn_senmail_Click(object sender, EventArgs e)
{
try
{
//here on button click what will done
// SendMail();
// Gmail Address from where you send the mail
var fromAddress = "vimalgowthaman14@gmail.com";
// any address where the email will be sending
var toAddress = txt_emailid.Text.ToString();
//Password of your gmail address
const string fromPassword = "xxxxxxxxx";
// Passing the values and make a email formate to display
string subject = "Free Dial Enquiry";
string body = "From: " + txt_name.Text + "\n";
body += "ContactNo::" + txt_cno.Text + "\n";
body += "Email: " + txt_emailid.Text + "\n";
body += "Subject: " + subject + "\n";
body += "Question: \n" + txx_msg.Text + "\n";
// smtp settings
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;
}
// Passing values to smtp object
smtp.Send(fromAddress, toAddress, subject, body);
lbl_msg.Visible = true;
lbl_msg.Text = "Send Mail";
txt_cno.Text = "";
txx_msg.Text = "";
txt_name.Text = "";
txt_emailid.Text = "";
// Comments.Text = "";
}
catch (Exception ex)
{
lbl_msg.Text = ex.ToString();
}
}
MY ERROR:
System.Net.Mail.SmtpException: The operation has timed out. at System.Net.Mail.SmtpClient.Send(MailMessage message) at System.Net.Mail.SmtpClient.Send(String from, String recipients, String subject, String body) at water_control.btn_senmail_Click(Object sender, EventArgs e) in e:\project-freedial1\industrial_machinery_Water Level Controller Dealers_coimbatore.aspx.cs:line 80 how to solve this error please anyone help me
gowthaman8870226416