public async Task Publish(HashSet <Transaction> increment, DateTime incrementFrom, DateTime incrementTo)
        {
            var fileName        = $"transactions-{incrementTo:s}.csv";
            var bccDestinations = string.Join(", ", _settings.Bcc);

            _log.Info($"Sending transactions increment '{fileName}' via email to address '{_settings.To}' and BCC '{bccDestinations}'...");

            using (var stream = new MemoryStream())
            {
                await _writer.WriteAsync(increment, stream, leaveOpen : true);

                stream.Position = 0;

                var base64Report = Convert.ToBase64String(stream.ToArray());
                var message      = new EmailMessage
                {
                    Subject     = $"Lykke transactions batch for the period {incrementFrom:s} - {incrementTo:s}",
                    TextBody    = $"Hi, please find enclosed the Lykke transactions batch for the period {incrementFrom:s} - {incrementTo:s} UTC, best regards",
                    Attachments = new[]
                    {
                        new EmailAttachment(fileName, "text/csv", base64Report)
                    }
                };
                var to = new EmailAddressee {
                    EmailAddress = _settings.To
                };
                var bcc = _settings.Bcc.Select(x => new EmailAddressee {
                    EmailAddress = x
                });

                await _emailSender.SendAsync(message, to, bcc);
            }

            _log.Info($"Transactions increment with {increment.Count} transactions sent via email");
        }
예제 #2
0
 public Task SendAsync(EmailMessage message, EmailAddressee to)
 {
     return(_log.WriteInfoAsync(nameof(EmailSenderLogStub), nameof(SendAsync), message?.ToJson(),
                                $"Email was send to {to.EmailAddress}"));
 }
예제 #3
0
 public Task SendAsync(EmailMessage message, EmailAddressee to)
 {
     return(Task.CompletedTask);
 }