private void sendEmail(string emailTo, string userId) { string UserName = LoginUser.UserName; using (StreamReader reader = File.OpenText(Server.MapPath("~/App_Data/ResetPwdEmailBody.txt"))) { string urlBase = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath; string verifyUrl = "/Account/UnlockAccount.aspx?uName=" + UserName + "&id=" + userId; string fullUrl = urlBase + verifyUrl; MailMessage msg = new MailMessage(); msg.Subject = "Unlock your account"; msg.IsBodyHtml = true; msg.To.Add(new MailAddress(emailTo, UserName)); msg.Body = reader.ReadToEnd(); msg.Body = msg.Body.Replace("<%resetPassword%>", fullUrl); msg.Body = msg.Body.Replace("<% UserName %>", UserName); msg.Priority = MailPriority.High; SmtpClient myClient = new SmtpClient(); myClient.EnableSsl = false; try { myClient.Send(msg); } catch (Exception ex) { LoginUser.FailureText = "Email cannot be send. Error: " + ex.Message; } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)