예제 #1
0
        public bool SendNotification(string email, VolunteerNotificationTemplate volunteerNotificationType)
        {
            var message = new MailMessage(_mailConfiguration.SiteEmailAddress, email)
            {
                Subject    = GetTemplate(volunteerNotificationType.ToString().ToLower() + "-subject"),
                Body       = GetTemplate(volunteerNotificationType.ToString().ToLower() + "-body"),
                IsBodyHtml = true
            };

            return(_sender.Send(message));
        }
        public async Task SendEmail(Email email)
        {
            var result = await _validator.ValidateAsync(email);

            if (!result.IsValid)
            {
                var validationMessage = _validationMessageFormatter.GetErrorMessage(result.Errors);
                throw new InvalidInputException(validationMessage);
            }

            try
            {
                await _smtpSender.Send(email);

                email.Success = true;
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Error when sending email");
                email.Success = false;
            }

            await _emailsRepository.Create(email);
        }