using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Net.Mail; public partial class ForgotPassword : WebBlockPage { protected void Page_Load(object sender, EventArgs e) { } protected void btnResetPassword_Click(object sender, EventArgs e) { DataRow dr = Database.Customers_GetNonOneTimeByEmailAddress(txtEmailAddress.Text, null); if (dr != null) { int CustomerID = (int)dr["CustomerID"]; string sPass = Utilities.GenerateRandomString(8); TemplatedEmail email = new TemplatedEmail(Page, "~/EmailTemplates/ForgotPassword.html"); email.TemplateVariables.Add("[[Password]]", sPass); email.To.Add(txtEmailAddress.Text); email.From = new MailAddress(Configuration.Get("Emails.ReplyEmail"), Configuration.Get("Emails.FromName")); email.Subject = "Password Reset Request"; email.Send(); Database.Customers_UpdatePassword(CustomerID, sPass); litError.Text = "Your password has been reset, and an email has been sent. You should receive your new password shortly."; } else { litError.Text = "No such user exists."; } } }