コード例 #1
0
 public async Task SendEmailAsync(string body)
 {
     await _smtpService.SendEmailAsync(
         _configuration.DefaultToAddress,
         _configuration.DefaultFromAddress,
         _configuration.DefaultSubject,
         body,
         _configuration.DefaultCCAddresses,
         _configuration.DefaultIsBodyHtml,
         _configuration.Username,
         _configuration.Password,
         _configuration.Timeout);
 }
コード例 #2
0
        private async Task SendEmailAsync(
            string to,
            string subject,
            string resourceUrl,
            Dictionary <string, string> dictionary
            )
        {
            var stream = File.OpenRead(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, resourceUrl));

            using var reader = new StreamReader(stream);
            var body = reader.ReadToEnd();

            foreach (var item in dictionary)
            {
                subject = subject.Replace($"{{{item.Key}}}", item.Value);
                body    = body.Replace($"{{{item.Key}}}", item.Value);
            }
            await _smtpService.SendEmailAsync(to, subject, body);
        }
コード例 #3
0
 public async Task SendEmail([FromBody] Email email)
 {
     await _smtpService.SendEmailAsync(email);
 }