-
Notifications
You must be signed in to change notification settings - Fork 46
Managing Suppressions
Vlad-Cosmin Sandu edited this page Apr 6, 2020
·
1 revision
The PostmarkClient
allows you to create, delete (reactivate) or search for Suppressed recipients.
var query = new PostmarkSuppressionQuery
{
SuppressionReason = "ManualSuppression", // filter by Suppression reason [optional]
Origin = "Customer", // filter by Suppression Origin [optional]
EmailAddress = "[email protected]", // filter by email address [optional]
FromDate = DateTime.UtcNow.AddDays(-2), // filter from the specified date [optional]
ToDate = DateTime.UtcNow.AddDays(-1) // filter up to the specified date [optional]
};
var suppressionListing = await _client.ListSuppressions(query);
foreach (var suppression in suppressionListing.Suppressions)
{
Console.WriteLine($"EmailAddress: {suppression.EmailAddress}");
Console.WriteLine($"SuppressionReason: {suppression.SuppressionReason}");
Console.WriteLine($"Origin: {suppression.Origin}");
Console.WriteLine($"CreatedAt: {suppression.CreatedAt.ToString("O")}");
}
var request = new PostmarkSuppressionChangeRequest { EmailAddress = "[email protected]" };
var result = await _client.CreateSuppressions(new List<PostmarkSuppressionChangeRequest> { request });
foreach (var suppressionRequest in result.Suppressions)
{
Console.WriteLine($"EmailAddress: {suppressionRequest.EmailAddress}"); // EmailAddress to suppress
Console.WriteLine($"Status: {suppressionRequest.Status.ToString()}"); // Status of the request
Console.WriteLine($"Message: {suppressionRequest.Message}"); // Optional message about the request. E.g.: Reason for failure
}
Suppressions will be generated with a Customer
Origin and will have a ManualSuppression
reason.
Note: Requests are processed asynchronously and can take a minute until they become active.
var request = new PostmarkSuppressionChangeRequest { EmailAddress = "[email protected]" };
var result = await _client.DeleteSuppressions(new List<PostmarkSuppressionChangeRequest> { request });
foreach (var reactivationRequest in result.Suppressions)
{
Console.WriteLine($"EmailAddress: {reactivationRequest.EmailAddress}"); // EmailAddress to reactivate
Console.WriteLine($"Status: {reactivationRequest.Status.ToString()}"); // Status of the request
Console.WriteLine($"Message: {reactivationRequest.Message}"); // Optional message about the request. E.g.: Reason for failure
}
Suppressions will only be reactivated if you have the required authority.
Note: Requests are processed asynchronously and can take a minute until they become active.
For more information, please check our Suppressions API Documentation.
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