/// <summary> /// Sends the message synchronously through the Postmark API. /// </summary> /// <param name="mail">The mail message to send.</param> public void Send(MailMessage mail) { var request = CreateEmailRequest(mail.ToPostmarkMessage()); var response = _client.Execute<PostmarkResponse>(request); if (response.ErrorException != null) throw response.ErrorException; if (response.Data.ErrorCode > 0) throw new PostmarkException(response.Data); }
/// <summary> /// Sends the message asynchronously through the Postmark API and calls /// the given callback when complete. /// </summary> /// <param name="mail">The mail message to send.</param> /// <param name="callback">The callback to execute when sending is complete.</param> public void SendAsync(MailMessage mail, Action<MailMessage> callback) { var request = CreateEmailRequest(mail.ToPostmarkMessage()); _client.ExecuteAsync<PostmarkResponse>(request, response => { if (response.ErrorException != null) throw response.ErrorException; if (response.Data.ErrorCode > 0) throw new PostmarkException(response.Data); callback(mail); }); }