public double Forgot_Password(double UserId, string strNewPassword) { try { //Get the Email Template ModelEmailTemplate objModelEmailTemplate = GetEmailTemplates("ADMIN_FORGOT_PASSWORD"); string StrEmailText = null; string strHeaderText = null; string strEmailSender = null; string strSMTP = null; string StrUsername = null; string StrPassword = null; string strAdminUserEmail = null; string strAdminUserFullName = null; string strAdminUserName = null; BLLAdminUser objDALAdminUser = new BLLAdminUser(); DataTable dtUserDetails = objDALAdminUser.GetAdminUserDetailsByUserNo(UserId); //Get Mail Data Based on User prefered Language Type strHeaderText = objModelEmailTemplate.EmailEN; //Get Data Based on Language StrEmailText = objModelEmailTemplate.EmailTextEN; strAdminUserEmail = dtUserDetails.Rows[0]["AdminUserEmail"].ToString(); strAdminUserFullName = dtUserDetails.Rows[0]["AdminUserFirstName"].ToString() + " " + dtUserDetails.Rows[0]["AdminUserLastName"].ToString(); strAdminUserName = dtUserDetails.Rows[0]["AdminUserName"].ToString(); //Get SMTP Username Password strSMTP = objModelEmailTemplate.EmailSMTP; StrUsername = objModelEmailTemplate.EmailUserName; StrPassword = objModelEmailTemplate.Emailpassword; strEmailSender = objModelEmailTemplate.EmailSender; Hashtable shs = new Hashtable(); shs["[$body]"] = StrEmailText; string strHeaderBody = DALUtility.StringReplace(strHeaderText, shs); //Set the Replace text for the Email body with user Details Details Hashtable hsh = new Hashtable(); hsh["[$AdminName]"] = strAdminUserFullName; hsh["[$password]"] = strNewPassword; hsh["[$username]"] = strAdminUserName; //Get the Email body by Replacing Text in Template string strEmailBody = DALUtility.StringReplace(strHeaderBody, hsh); //Send Email if ((BLLEmail.SendEmail(strAdminUserEmail, objModelEmailTemplate.EmailSender, objModelEmailTemplate.EmailSubjectEN, strEmailBody, objModelEmailTemplate.EmailSMTP, objModelEmailTemplate.EmailUserName, objModelEmailTemplate.Emailpassword) > 0)) { return 1; } } catch (Exception ex) { DALUtility.ErrorLog(ex.Message, "Forgot_Password"); } return 0; }
public double Forgot_Password(double UserId, string strNewPassword) { try { //Get the Email Template ModelEmailTemplate objModelEmailTemplate = GetEmailTemplates("ADMIN_FORGOT_PASSWORD"); string StrEmailText = null; string strHeaderText = null; string strEmailSender = null; string strSMTP = null; string StrUsername = null; string StrPassword = null; string strAdminUserEmail = null; string strAdminUserFullName = null; string strAdminUserName = null; BLLAdminUser objDALAdminUser = new BLLAdminUser(); DataTable dtUserDetails = objDALAdminUser.GetAdminUserDetailsByUserNo(UserId); //Get Mail Data Based on User prefered Language Type strHeaderText = objModelEmailTemplate.EmailEN; //Get Data Based on Language StrEmailText = objModelEmailTemplate.EmailTextEN; strAdminUserEmail = dtUserDetails.Rows[0]["AdminUserEmail"].ToString(); strAdminUserFullName = dtUserDetails.Rows[0]["AdminUserFirstName"].ToString() + " " + dtUserDetails.Rows[0]["AdminUserLastName"].ToString(); strAdminUserName = dtUserDetails.Rows[0]["AdminUserName"].ToString(); //Get SMTP Username Password strSMTP = objModelEmailTemplate.EmailSMTP; StrUsername = objModelEmailTemplate.EmailUserName; StrPassword = objModelEmailTemplate.Emailpassword; strEmailSender = objModelEmailTemplate.EmailSender; Hashtable shs = new Hashtable(); shs["[$body]"] = StrEmailText; string strHeaderBody = DALUtility.StringReplace(strHeaderText, shs); //Set the Replace text for the Email body with user Details Details Hashtable hsh = new Hashtable(); hsh["[$AdminName]"] = strAdminUserFullName; hsh["[$password]"] = strNewPassword; hsh["[$username]"] = strAdminUserName; //Get the Email body by Replacing Text in Template string strEmailBody = DALUtility.StringReplace(strHeaderBody, hsh); //Send Email if ((BLLEmail.SendEmail(strAdminUserEmail, objModelEmailTemplate.EmailSender, objModelEmailTemplate.EmailSubjectEN, strEmailBody, objModelEmailTemplate.EmailSMTP, objModelEmailTemplate.EmailUserName, objModelEmailTemplate.Emailpassword) > 0)) { return(1); } } catch (Exception ex) { DALUtility.ErrorLog(ex.Message, "Forgot_Password"); } return(0); }