/// <summary> /// Adds the mail message to the email queue. /// </summary> /// <param name="message"> /// The mail message. /// </param> public void Enqueue(MailMessage message) { if (message == null) throw new ArgumentNullException("message"); // We have to send the message on a background thread because integration services can't make async calls. // We should probably store the email queue in the database and send the messages on a background thread // so that users don't receive invalid messages in case the transaction is rolled back after the message was sent. Task.Run(() => SendAsync(message)); }
private async Task SendAsync(MailMessage message) { try { await EmailManager.SendEmailAsync( message.Email, string.Empty, string.Empty, message.Subject, message.Body, true, message.ProcessName, message.ItemId ?? 0, Constants.Action, null); } catch (Exception ex) { Logger.Log(LogSeverity.Error, "Email Queue", ex); } }