private async Task <ValidationResult> SendSellerConfirmationEmail(Seller seller, string callbackUrl) { var validationResult = new ValidationResult(); var personnelConfirmedEmail = new PersonnelCreatedEmail() { CallBackUrl = callbackUrl, Subject = "Confirm your account", TemplateName = "PersonnelCreatedEmail", ToAddress = new List <string>() { seller.Email } }; try { await _personnelEmailBusinessService.SendConfirmationMail(personnelConfirmedEmail); validationResult.Succeeded = true; } catch (Exception ex) { validationResult.Succeeded = false; validationResult.Exception = ex; } return(validationResult); }
public async Task <ActionResult> ForgotPassword(ForgotPasswordViewModel model) { if (ModelState.IsValid) { var user = await UserManager.FindByNameAsync(model.Email); if (user == null || !(await UserManager.IsEmailConfirmedAsync(user.Id))) { // Don't reveal that the user does not exist or is not confirmed return(View("ForgotPasswordConfirmation")); } // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link string code = await UserManager.GeneratePasswordResetTokenAsync(user.Id); var callbackUrl = Url.Action("ResetPassword", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); //--------------------------------------------------------------------- var validationResult = new ValidationResult(); var forgotEmail = new PersonnelCreatedEmail() { FullName = user.Email, CallBackUrl = callbackUrl, Subject = "Confirm your account", TemplateName = "ForgotPassword", ToAddress = new List <string>() { model.Email }, FromAddress = "*****@*****.**" }; try { await PersonnelEmailBusinessService.SendForgotMail(forgotEmail); validationResult.Succeeded = true; return(RedirectToAction("ForgotPasswordConfirmation", "Account")); } catch (Exception ex) { validationResult.Succeeded = false; //return validationResult; } //var userEmailData = new EmailData() //{ // BCCAddressList = new List<string> { "*****@*****.**" }, // Body = String.Format("To reset your password by clicking < a href =\"" + callbackUrl + "\">here</a>"), // Subject = "Reset Password (Mumbile.com)", // IsHtml = true, // ToAddressList = new List<string> { user.Email } //}; //_emailBusinessService.SendEmail(userEmailData); //return RedirectToAction("ForgotPasswordConfirmation", "Account"); } // If we got this far, something failed, redisplay form return(View(model)); }
public async Task SendForgotMail(PersonnelCreatedEmail forgotEmail) { var templateJson = forgotEmail.ToJson(); var body = _templateBusinessService.CreateText(templateJson, forgotEmail.TemplateName); if (body == null) { return; } await _emailBusinessService.SendEmail(new EmailData { Subject = forgotEmail.Subject, //ToDo ToAddressList = forgotEmail.ToAddress, IsHtml = true, Body = body }); }
public async Task SendConfirmationMail(PersonnelCreatedEmail personnelCreatedEmail) { var templateJson = personnelCreatedEmail.ToJson(); var body = _templateBusinessService.CreateText(templateJson, personnelCreatedEmail.TemplateName); if (body == null) { return; } try { await _emailBusinessService.SendEmail(new EmailData { Subject = personnelCreatedEmail.Subject, //ToDo ToAddressList = personnelCreatedEmail.ToAddress, IsHtml = true, Body = body }); } catch (Exception) { throw new Exception(); } }