public static ForgotPasswordInfo ForgotPassword(string email) { User users = UserAuthentication.GetUserByEmailId(email); ForgotPassword forgotPassword; ForgotPasswordInfo forgotPasswordInfo = new ForgotPasswordInfo(); if (users == null) { forgotPasswordInfo.Success = false; forgotPasswordInfo.ErrorMsg = "Email address entered by you is not registered with us. Please enter the valid email address which you use for login."; return(forgotPasswordInfo); } UserAuthentication.SaveForgotPassword(users); forgotPassword = UserAuthentication.GetForgotPasswordByUserID(users.UserId); forgotPasswordInfo.Success = true; forgotPasswordInfo.ForgotPasswordId = forgotPassword.ForgotPasswordId; StringBuilder emailBody = new StringBuilder(ConstructMail.GetMailBody(Constant.FORGOT_PASSWORD)); emailBody = emailBody.Replace(Constant.CONST_USERNAME, users.FirstName).Replace(Constant.CONST_FORGOTLINK, forgotPassword.ForgotPasswordId.ToString()); emailBody = emailBody.Replace(Constant.CONST_FIRSTNAME, users.FirstName); emailBody = emailBody.Replace(Constant.CONST_LASTNAME, users.LastName); if (!SendMail.Sendmail(email, Constant.CONST_RESETPASSWORD_SUBJECT, emailBody.ToString())) { forgotPasswordInfo.Success = false; forgotPasswordInfo.ErrorMsg = "Error occurred while sending email. Please try again."; return(forgotPasswordInfo); } return(forgotPasswordInfo); }