Created
October 2, 2015 15:18
-
-
Save jptoto/374969e4c436226aa741 to your computer and use it in GitHub Desktop.
PM Async Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Send an email with the Postmark .NET library | |
// Learn more -> http://developer.postmarkapp.com/developer-official-libs.html#dot-net | |
// Install with NuGet | |
PM> Install-Package Postmark | |
// Import | |
using PostmarkDotNet; | |
// Example asynchronous request | |
var message = new PostmarkMessage() | |
{ | |
To = "recipient@example.com", | |
From = "sender@example.com", | |
TrackOpens = true, | |
Subject = "A complex email", | |
TextBody = "Plain Text Body", | |
HtmlBody = "<html><body><img src=\"cid:embed_name.jpg\"/></body></html>", | |
Tag = "New Year's Email Campaign", | |
Headers = new HeaderCollection{ | |
{"X-CUSTOM-HEADER", "Header content"} | |
} | |
}; | |
var imageContent = File.ReadAllBytes("test.jpg"); | |
message.AddAttachment(imageContent, "test.jpg", "image/jpg", "embed_name.jpg"); | |
var client = new PostmarkClient("<server token>") | |
var sendResult = await client.SendMessageAsync(message); | |
if (sendResult.Status == PostmarkStatus.Success){ /* Handle success */ } | |
else { /* Resolve issue.*/ } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment