/// <summary> /// Does the actual work of sending the <see cref="IFormattedNotificationMessage"/> /// </summary> /// <param name="message">The <see cref="IFormattedNotificationMessage"/> to be sent</param> public override void PerformSend(IFormattedNotificationMessage message) { if (!message.Recipients.Any()) { return; } using (var msg = new MailMessage { From = new MailAddress(message.From), Subject = message.Name, Body = message.BodyText, IsBodyHtml = true }) { // REFACTOR update to MultiLogHelper when we control Resolution Freeze LogHelper.Info <SmtpNotificationGatewayMethod>("Sending an email to " + string.Join(", ", message.Recipients)); foreach (var to in message.Recipients) { if (!string.IsNullOrEmpty(to)) { msg.To.Add(new MailAddress(to)); } } // Event raised to allow further modification to msg (like attachments) Sending.RaiseEvent(new ObjectEventArgs <MailMessage>(msg), this); this.Send(msg); } }
/// <summary> /// Does the actual work of sending the <see cref="IFormattedNotificationMessage"/> /// </summary> /// <param name="message">The <see cref="IFormattedNotificationMessage"/> to be sent</param> public override void PerformSend(IFormattedNotificationMessage message) { if (!message.Recipients.Any()) return; var msg = new MailMessage { From = new MailAddress(message.From), Subject = message.Name, Body = message.BodyText, IsBodyHtml = true }; MultiLogHelper.Info<SmtpNotificationGatewayMethod>("Sending an email to " + string.Join(", ", message.Recipients)); foreach (var to in message.Recipients) { if (!string.IsNullOrEmpty(to)) { msg.To.Add(new MailAddress(to)); } } // Event raised to allow further modification to msg (like attachments) Sending.RaiseEvent(new ObjectEventArgs<MailMessage>(msg), this); this.Send(msg); }
/// <summary> /// Does the actual work of sending the <see cref="IFormattedNotificationMessage"/> /// </summary> /// <param name="message">The <see cref="IFormattedNotificationMessage"/> to be sent</param> public override void PerformSend(IFormattedNotificationMessage message) { if (!message.Recipients.Any()) { return; } var msg = new MailMessage { From = new MailAddress(message.From), Subject = message.Name, Body = message.BodyText, IsBodyHtml = true }; foreach (var to in message.Recipients) { if (!string.IsNullOrEmpty(to)) { msg.To.Add(new MailAddress(to)); } } //// We want to send the email async ////Task<bool> sendAsync = this.SendAsync(msg); this.Send(msg); }
/// <summary> /// Does the actual work of sending the <see cref="IFormattedNotificationMessage"/> /// </summary> /// <param name="message">The <see cref="IFormattedNotificationMessage"/> to be sent</param> public override void PerformSend(IFormattedNotificationMessage message) { if (!message.Recipients.Any()) return; var msg = new MailMessage { From = new MailAddress(message.From), Subject = message.Name, Body = message.BodyText, IsBodyHtml = true }; foreach (var to in message.Recipients) { if (!string.IsNullOrEmpty(to)) { msg.To.Add(new MailAddress(to)); } } //// We want to send the email async ////Task<bool> sendAsync = this.SendAsync(msg); this.Send(msg); }
/// <summary> /// Does the actual work of sending the <see cref="IFormattedNotificationMessage"/> /// </summary> /// <param name="message">The <see cref="IFormattedNotificationMessage"/> to be sent</param> public override void PerformSend(IFormattedNotificationMessage message) { if (!message.Recipients.Any()) { return; } var msg = new MailMessage { From = new MailAddress(message.From), Subject = message.Name, Body = message.BodyText, IsBodyHtml = true }; foreach (var to in message.Recipients) { if (!string.IsNullOrEmpty(to)) { msg.To.Add(new MailAddress(to)); } } //// We want to send the email async Task.Factory.StartNew(() => { try { using (msg) { using (var sender = new SmtpClient(_settings.Host)) { if (_settings.HasCredentials) { sender.Credentials = _settings.Credentials; } if (_settings.EnableSsl) { sender.EnableSsl = true; } sender.Send(msg); } } } catch (Exception ex) { LogHelper.Error <SmtpNotificationGatewayMethod>("SMTP provider failed sending email", ex); } }); }
/// <summary> /// Does the actual work of sending the <see cref="IFormattedNotificationMessage"/> /// </summary> /// <param name="message">The <see cref="IFormattedNotificationMessage"/> to be sent</param> public override void PerformSend(IFormattedNotificationMessage message) { if (!message.Recipients.Any()) return; var msg = new MailMessage { From = new MailAddress(message.From), Subject = message.Name, Body = message.BodyText, IsBodyHtml = true }; foreach (var to in message.Recipients) { if (!string.IsNullOrEmpty(to)) { msg.To.Add(new MailAddress(to)); } } //// We want to send the email async Task.Factory.StartNew(() => { try { using (msg) { using (var sender = new SmtpClient(_settings.Host)) { if (_settings.HasCredentials) sender.Credentials = _settings.Credentials; if (_settings.EnableSsl) sender.EnableSsl = true; sender.Send(msg); } } } catch (Exception ex) { LogHelper.Error<SmtpNotificationGatewayMethod>("SMTP provider failed sending email", ex); } }); }
/// <summary> /// Does the actual work of sending the <see cref="IFormattedNotificationMessage"/> /// </summary> /// <param name="message"> /// The <see cref="IFormattedNotificationMessage"/> to be sent /// </param> /// <param name="attachments"> /// The attachments. /// </param> public override void PerformSend(IFormattedNotificationMessage message, IEnumerable <Attachment> attachments = null) { if (!message.Recipients.Any()) { return; } using (var msg = new MailMessage { From = new MailAddress(message.From), Subject = message.Name, Body = message.BodyText, IsBodyHtml = true }) { LogHelper.Info <SmtpNotificationGatewayMethod>("Sending an email to " + string.Join(", ", message.Recipients)); foreach (var to in message.Recipients) { if (!string.IsNullOrEmpty(to)) { msg.To.Add(new MailAddress(to)); } } if (attachments != null) { foreach (var att in attachments) { msg.Attachments.Add(att); } } // Event raised to allow further modification to msg (like attachments) Sending.RaiseEvent(new ObjectEventArgs <MailMessage>(msg), this); this.Send(msg); } }
/// <summary> /// Does the actual work of sending the <see cref="IFormattedNotificationMessage"/> /// </summary> /// <param name="message">The <see cref="IFormattedNotificationMessage"/> to be sent</param> public abstract void PerformSend(IFormattedNotificationMessage message);
/// <summary> /// Does the actual work of sending the <see cref="IFormattedNotificationMessage"/> /// </summary> /// <param name="message"> /// The <see cref="IFormattedNotificationMessage"/> to be sent /// </param> /// <param name="attachments"> /// The attachments. /// </param> public abstract void PerformSend(IFormattedNotificationMessage message, IEnumerable <Attachment> attachments = null);
/// <summary> /// Does the actual work of sending the <see cref="IFormattedNotificationMessage"/> /// </summary> /// <param name="message">The <see cref="IFormattedNotificationMessage"/> to be sent</param> public abstract void PerformSend(IFormattedNotificationMessage message);