-
Notifications
You must be signed in to change notification settings - Fork 48
Sending text and html email messages
First, let's create our PostmarkMessage
object:
var message = new PostmarkMessage();
We can now add recipients to the To
, CC
, and BCC
fields as needed.
message.To = "[email protected]";
message.Cc = "[email protected]";
message.Subject = "A fun test email!";
message.TextBody = "Some plain text";
message.From = "[email protected]";
We'll need a PostmarkClient
object in order to send our message.
var client = new PostmarkClient("server_token");
Now we're ready to send our message.
var response = client.SendMessage(message);
If there is a problem sending your message to the API, the error message will be contained in the response
object. Note: When sending messages in this fashion, you may only add one address to each of the To
, CC
, and BCC
fields.
To send an HTML-based email, simply add the HtmlBody field to the message
object.
message.HtmlBody = "<h1>Hello!</h1>";
By setting TrackOpens to true
we can use Postmark's open tracking feature. Enabling/disabling tracking can also be done on a per-server basis, and can be overridden on a per-message basis.
message.TrackOpens = true;
The Postmark.Net client can be installed from NuGet.
For additional information about the capabilities of the Postmark API, see http://developer.postmarkapp.com/.
- Getting Started
- Version 2.0 Upgrade Guide
- Sending Email
- Searching Sent Messages
- Analyzing Sent Messages
- Processing Inbound Email
- Retrieving Message Statistics
- Handling Bounces
- Managing Suppressions
- Working with Message Streams
- Managing Your Account
- Troubleshooting Async&Await
- Version 1.x Overview
- Sending Email
- Sending Batch Emails
- Sending Attachments
- Sending Inline Images
- Using
MailMessage
- Using the Bounce API
- [Getting Send Statistics](Sending Statistics)
- Adding Custom Email Headers