Niranjan Poddar

Niranjan Poddar

  • 875
  • 648
  • 95.6k

sending mail error(gmail)

Mar 11 2015 6:00 AM
Dear all,
 
 
 Please give me solution: 
 
before i used this code it was working.............
 
string Email = dtUser.Rows[0]["VC_EMAIL"].ToString().Trim();
string uid = Encrypt(dtUser.Rows[0]["IN_ID"].ToString());
string UsName = Encrypt(dtUser.Rows[0]["VC_USERNAME"].ToString());
MailMessage mail = new MailMessage();
mail.To.Add(txtMail.Text.ToString().Trim());
 
mail.From = new MailAddress("[email protected]");
mail.Subject = "RIDF Reset Password link";
 
string Body = "<h2><u> Request for Reset Password </u></h2><br/><a href='http://localhost:2536/RIDF/ResetPassword.aspx?uid=" + uid + "&dn=" + UsName + "' target='_blank'>Please Reset your password....</a> ";
 
mail.Body = Body;
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address
 

smtp.Credentials = new System.Net.NetworkCredential
("[email protected]", "fdafds");
smtp.Port = 587;
//sendEmail(Body, Email);

smtp.EnableSsl = true;
smtp.UseDefaultCredentials = true;
smtp.Send(mail);
return true; 
 
 
but this code is not working now:
 
showing error -An exception of type 'System.Net.Mail.SmtpException' occurred in System.dll but was not handled in user code

Additional information: Failure sending mail.

Answers (2)