how to solve this error [Resolved]

Posted by Gow.Net under ASP.NET on 6/27/2012 | Points: 10 | Views : 6250 | Status : [Member] | Replies : 3
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


Responses

Posted by: Gemamgall on: 6/27/2012 [Member] Starter | Points: 50

Up
0
Down

Resolved
Remove line mentioned below

smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;

smtp.Timeout = 20000;


If you still face error , let me know

Thanks and Regards,

Vinay Gandhi
www.quadtechindia.com

Gow.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gemamgall on: 6/27/2012 [Member] Starter | Points: 50

Up
0
Down

Resolved
Remove line mentioned below

smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;

smtp.Timeout = 20000;


If you still face error , let me know

Thanks and Regards,

Vinay Gandhi
www.quadtechindia.com

Gow.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Btrack124 on: 6/28/2012 [Member] Starter | Points: 25

Up
0
Down
As Vinay suggested remove both the Lines
and also check for SSL Enabled property whether it enabled in the server through which you are trying to send the mail
Thanks
http://www.alacraft.com.au/

Roland Masten

Gow.Net, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response