public void ForgotPassword(UserVM _userVM) { HttpContext.Response.ContentType = "application/json; charset=utf-8"; try { //Check If User Exists _userVM = _userBLL.ForgotPassword(_userVM); if (_userVM != null) { //Fetching Email Body Text from EmailTemplate File. string FilePath = Server.MapPath(@"~\EmailTemplates") + @"\ForgotPassword.html"; StreamReader str = new StreamReader(FilePath); string MailText = str.ReadToEnd(); str.Close(); //Repalce EmailTemplate Parameters MailText = MailText.Replace("[#SHPOT]", "SHPOT"); MailText = MailText.Replace("[#FirstName]", _userVM.FirstName); MailText = MailText.Replace("[#FullName]", _userVM.FirstName + " " + _userVM.LastName); MailText = MailText.Replace("[#ActionURL]", Common.APIURL + "/Web/UserEmail/ResetUserPassword/" + _userVM.ResetToken); MailText = MailText.Replace("[#SupportURL]", Common.APIURL + "/Web/UserEmail/AddSupportQuery/"); String _fromEmail = Common.SMTPUserName; String _fromName = "SHPOT Admin"; String _toEmail = _userVM.Email; String _toName = _userVM.FirstName; SendEmailNotifications(_fromEmail, _fromName, _toEmail, _toName, MailText, "Password Reset URL - SHPOT"); HttpContext.Response.Write("{\"status\": \"Success\","); HttpContext.Response.Write("\"Message\": \"A link has been sent to your email.\"}"); } else { HttpContext.Response.Write("{\"status\": \"Failed\","); HttpContext.Response.Write("\"Message\": \"User does not exists.\"}"); } } catch (Exception ex) { HttpContext.Response.Write("{\"status\": \"Failed\", "); HttpContext.Response.Write("\"Message\": \"" + ex.Message + "\"}"); } }