string subject = "Forget Password";
StringBuilder Bodymsg = new StringBuilder();
string smtpPort = ConfigurationManager.AppSettings.Get("SmtpPort").ToString();
string smtpUser = ConfigurationManager.AppSettings.Get("smtpUsername").ToString();
string smtpPassword =ConfigurationManager.AppSettings.Get("smtpPassword").ToString();
string SmtpAddress = ConfigurationManager.AppSettings.Get("SmtpAddress").ToString();
bool enablessl = Convert.ToBoolean(ConfigurationManager.AppSettings.Get("enablessl"));
string toAddress = email;
Bodymsg.Append("Dear " + name + "</br> Your User Id=" + email + "</br> and Password=" + Password + "</br> Thank </br>" + smtpUser);
MailMessage mailMessage = new MailMessage(smtpUser, toAddress);
mailMessage.Subject = subject;
mailMessage.Body = Bodymsg.ToString();
SmtpClient mailSender = new SmtpClient(SmtpAddress, Convert.ToInt32(smtpPort));
mailSender.EnableSsl = Convert.ToBoolean(enablessl);
NetworkCredential myCreds = new NetworkCredential(smtpUser, smtpPassword);
mailSender.Credentials = myCreds;
mailMessage.IsBodyHtml = true;
mailSender.Send(mailMessage);
return "1";
No comments:
Post a Comment