コード例 #1
0
ファイル: EmailLogger.cs プロジェクト: masums/ITCC.Library
 private async Task SendEmailAsync(string subject, string body, MailPriority priority)
 {
     try
     {
         using (var client = new SmtpClient
         {
             Port = SmptPort, Host = SmtpHost, EnableSsl = true, Timeout = 10000, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Credentials = new System.Net.NetworkCredential(Login, Password),
         })
         {
             var mailMessage = new MailMessage(Sender, Receivers.First(), subject, body)
             {
                 BodyEncoding = Encoding.UTF8, DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure, Priority = priority
             };
             Receivers.ForEach(r =>
             {
                 if (mailMessage.To.All(ma => ma.Address != r))
                 {
                     mailMessage.To.Add(r);
                 }
             });
             await client.SendMailAsync(mailMessage);
         }
     }
     catch (Exception ex)
     {
         Logger.LogException("MAIL LOG", LogLevel.Warning, ex);
     }
 }
コード例 #2
0
 public Action <byte> GetCurrentReceiver()
 {
     return(Receivers.First(p => true));
 }