Beispiel #1
0
 private MailMessage CreateMessage(IFileInfo fileInfo)
 {
     return(_messageBuilder
            .Create()
            .SetSenderAddress(_settings.Mail.SenderEmailAddres)
            .SetDestinationAddresses(_settings.Mail.ToEmailAddreses)
            .SetSubject(_settings.Mail.Subject)
            .SetBody(_settings.Mail.Body)
            .AddAttachment(fileInfo.Open(FileMode.Open, FileAccess.Read, FileShare.Read), fileInfo.Name)
            .Build());
 }
Beispiel #2
0
        public async Task Send(Email email)
        {
            var mailMessage = _mailMessageBuilder.Create(email);
            var smtpClient  = new SmtpClient(_smtpConfiguration.Value.Server, _smtpConfiguration.Value.Port)
            {
                EnableSsl   = true,
                Credentials =
                    new NetworkCredential(_smtpConfiguration.Value.UserName, _smtpConfiguration.Value.Password)
            };
            await smtpClient.SendMailAsync(mailMessage);

            smtpClient.Dispose();
        }
Beispiel #3
0
 public void SetUp()
 {
     _builder = new MailMessageBuilder(_logger);
     _builder.Create();
 }