/// <summary> /// Records the and send request. /// </summary> /// <param name="userId">The user id.</param> /// <param name="username">The username.</param> /// <param name="email">The email.</param> private void RecordAndSendRequest(UserInfo user) { double ExpiryTime = 2; if (Settings["ExpiryTime"] != null) { ExpiryTime = Convert.ToDouble(Settings["ExpiryTime"]); } var myRequest = new PasswordResetRequest { PortalId = PortalId, UserId = user.UserID, ExpirationDate = DateTime.Now.AddHours(ExpiryTime), RecoveryCode = Guid.NewGuid().ToString() }; myRequest = PasswordRecoveryController.InsertRequest(myRequest); var notificationEmail = new StringBuilder(Localization.GetString("ResetEmail", LocalResourceFile)); notificationEmail.Replace("[PORTALNAME]", PortalSettings.PortalName); notificationEmail.Replace("[FIRSTNAME]", !string.IsNullOrEmpty(user.FirstName) ? user.FirstName : user.Username); notificationEmail.Replace("[LASTNAME]", !string.IsNullOrEmpty(user.LastName) ? user.LastName : string.Empty); notificationEmail.Replace("[DISPLAYNAME]", !string.IsNullOrEmpty(user.DisplayName) ? user.DisplayName : user.Username); notificationEmail.Replace("[USERNAME]", user.Username); var url = UrlUtility.GenerateResetUrl(TabId, myRequest.RecoveryCode); if (!url.ToLower().StartsWith("http")) { url = "http://" + PortalSettings.PortalAlias.HTTPAlias + url; } notificationEmail.Replace("[RESETLINK]", url); notificationEmail.Replace("[CODE]", myRequest.RecoveryCode); url = UrlUtility.GetPortalUrl(PortalSettings.HomeTabId); notificationEmail.Replace("[PORTALURL]", url); try { Mail.SendMail(PortalSettings.Email, user.Email, string.Empty, Localization.GetString("ResetEmailSubject", LocalResourceFile), notificationEmail.ToString(), string.Empty, "HTML", string.Empty, string.Empty, string.Empty, string.Empty); } catch (Exception ex) { Exceptions.LogException(ex); } }