예제 #1
0
        public async Task <EmailNotificationResponse> SendAsync(EmailNotificationRequest request)
        {
            var response = new EmailNotificationResponse();

            try
            {
                using (var mail = _mailMessageFactory.Create(request))
                    using (var client = new SmtpClient())
                    {
                        await client.SendMailAsync(mail).ConfigureAwait(false);
                    }

                response.IsSent = true;
            }
            catch (Exception e)
            {
                response.Message = e.Message;
                Log.Error($"Email failed to: {request.To}. Subject: {request.Subject}", e);
            }

            return(response);
        }
예제 #2
0
        public EmailNotificationResponse Send(EmailNotificationRequest request)
        {
            var response = new EmailNotificationResponse();

            try
            {
                using (var mail = _mailMessageFactory.Create(request))
                    using (var client = new SmtpClient())
                    {
                        client.Send(mail);
                    }

                response.IsSent = true;
            }
            catch (Exception e)
            {
                response.Message = e.Message;
                Log.Error($"Email failed to: {request.To}. Subject: {request.Subject}", e);
            }

            return(response);
        }