public bool Send(EmailAggregate email) { _validator.ValidateAndThrow(email); _emailSenderService.Send(email); email.SetEmailStatus(EmailStatus.Sent); _repository.Save(email); return(true); }
public IActionResult SendEmail() { logger.LogInformation("Enviando correo electrónico..."); logger.LogError("Ha ocurrido un error"); emailSenderService.Send(null, null, null); return(Ok()); }
public RegisterResult Register(Data.User user) { user.RegisterDate = DateTime.Now; user.Active = true; user.ApprovedEmail = false; user.Guid = Guid.NewGuid(); _emailSenderService.Send(new EmailMessageModel { Receiver = new List <string> { user.Email }, Subject = "Üyeliği Aktifleştir", MessageBody = "Üyeliğiniz Oluşturuldu. <a href=\"http://localhost:54244/User/ConfirmEmail?CustomerGuid=" + user.Guid.ToString() + " \"> Aktifleştirin</a> " }); appDbContext.Users.Add(user); appDbContext.SaveChanges(); return(RegisterResult.Successful); }
private async Task SendEmails() { var result = await _emailsRepository.GetPendingEmails(); foreach (var email in result.Response) { _emailSenderService.Send(email.Sender, email.Recipients, email.Subject, email.Body); await _emailsRepository.MarkEmailAsSent(email.Id); } }
public override void Handle(UserCreated message) { var password = message.Data.Password; var login = message.Data.Email; var subject = _translationsService.GetTranslationByKey("email.companyRegisteredSubject"); var body = string.Format(_translationsService.GetTranslationByKey("email.companyRegisteredBody"), login, password); _emailSenderService.Send(login, subject, body); }
public async Task <ActionResult> SendFullScheduleToAddress(EmailContent emailContent) { try { if (string.IsNullOrWhiteSpace(emailContent.Address)) { return(BadRequest("Address cannot be empty")); } if (string.IsNullOrWhiteSpace(emailContent.Subject)) { return(BadRequest("Subject cannot be empty")); } if (string.IsNullOrWhiteSpace(emailContent.Body)) { return(BadRequest("Email body cannot be empty")); } if (string.IsNullOrWhiteSpace(emailContent.SendMeetsUpUntilThisDate) || !DateTime.TryParse( emailContent.SendMeetsUpUntilThisDate, out DateTime latestDate)) { return(BadRequest($"Meets date range is invalid: \"{emailContent.SendMeetsUpUntilThisDate}\".")); } string[] emailAddresses = emailContent.Address.Split(';'); IEnumerable <MeetDetailsModel> meets = await _meetsService.RetrieveMeets( DateTime.Now, latestDate); string emailBody = FullScheduleEmailBuilder.Build( meets, $@"{_hostingEnvironment.WebRootPath}\templates", emailContent.Body, _meetsPageUrl, false); _logger.LogInfo($"Sending full schedule email to address \"{emailAddresses.Join(";")}\"...", ClassName); _emailSenderService.Send( emailContent.Subject, emailBody, emailAddresses); } catch (Exception ex) { _logger.LogError("Exception while sending full schedule email to address.", ClassName, ex); return(StatusCode(500, ex.Message)); } return(new JsonResult(Ok())); }
private static void SendDocumentViaEmail(IEmailSenderService senderService) { AppLogger.Info($"Sending document to email address {EmailSenderPreferences.EmailAddress}."); try { senderService.Send(); } catch (Exception) { AppLogger.Info( $"Сonfirmation of sending is required or can't send document to email address {EmailSenderPreferences.EmailAddress}."); return; } AppLogger.Info("Sending complete."); }
public Guid Create(ResetCreateRequest req) { Guid newToken = default(Guid); string userName = ""; int userId = 0; dataProvider.ExecuteNonQuery( "PasswordReset_Create", inputParamMapper: (parameters) => { parameters.AddWithValue("@Email", req.Email); parameters.Add("@Token", SqlDbType.UniqueIdentifier).Direction = ParameterDirection.Output; parameters.Add("@UserName", SqlDbType.NVarChar, 100).Direction = ParameterDirection.Output; parameters.Add("@UserId", SqlDbType.Int).Direction = ParameterDirection.Output; }, returnParameters: (parameters) => { userName = (string)parameters["@UserName"].Value; newToken = (Guid)parameters["@Token"].Value; userId = (int)parameters["@UserId"].Value; }); string openUrl = "password-reset?token=" + HttpUtility.UrlEncode(newToken.ToString()); StringBuilder email = new StringBuilder(); email.Append("Hi " + userName + ","); email.Append(Environment.NewLine + Environment.NewLine); email.Append("We've received a request to reset your RecruitHub password."); email.Append(Environment.NewLine + Environment.NewLine); email.Append("To reset your password please click on this link or cut and paste this URL into your browser:"); email.Append(Environment.NewLine + Environment.NewLine); email.Append(openUrl); email.Append(Environment.NewLine + Environment.NewLine); email.Append("If you did not request a password reset, please ignore this email. Link will expire in 24 hours."); email.Append(Environment.NewLine + Environment.NewLine); email.Append("Thank you,"); email.Append(Environment.NewLine + Environment.NewLine); email.Append("RecruitHub Team"); string emailBody = email.ToString(); emailSenderService.Send("RecruitHub", "*****@*****.**", userName, req.Email, "Password Reset", emailBody, null); return(newToken); }
public virtual ActionResult SendEmail(IndexModel model) { if (!ModelState.IsValid) { return(RedirectToAction(MVC.Contact.Index())); } Email email = _mapper.Map <IndexModel, Email>(model); try { _emailSenderService.Send(email); } catch (ValidationException e) { ControllerUtil.AddModelErrors(ModelState, e); return(RedirectToAction(MVC.Contact.Index())); } ViewData.Model = _mapper.Map <IndexModel, EmailSentModel>(model); return(RedirectToAction(MVC.Contact.EmailSent())); }
public async Task InvokeAsync(HttpContext context, IEmailSenderService emailSenderService) { emailSenderService.Send(null, null, null); await nextMiddleware(context); }