-
Notifications
You must be signed in to change notification settings - Fork 46
Working with Message Streams
Vlad-Cosmin Sandu edited this page May 28, 2020
·
1 revision
The PostmarkClient
allows you to easily manage your Message Streams.
var fetchedStream = await _client.GetMessageStream("my-stream-id");
Console.WriteLine($"StreamID: {fetchedStream.ID}");
Console.WriteLine($"ServerID: {fetchedStream.ServerID}");
Console.WriteLine($"Stream Type: {fetchedStream.MessageStreamType}");
Console.WriteLine($"Stream Name: {fetchedStream.Name}");
Console.WriteLine($"Stream Description: {fetchedStream.Description}");
var messageStreamType = MessageStreamTypeFilter.Transactional; // Filter by stream type; Defaults to All.
var includeArchivedStreams = true;
var listing = await _client.ListMessageStreams(messageStreamType, includeArchivedStreams);
foreach (var stream in listing.MessageStreams)
{
Console.WriteLine($"StreamID: {stream.ID}");
}
var id = "new-stream-id";
var streamType = MessageStreamType.Broadcasts;
var streamName = "New Broadcasts Stream";
var description = "This is a test description."; // optional
var messageStream = await _client.CreateMessageStream(id, streamType, streamName, description);
Console.WriteLine($"StreamID: {messageStream.ID}");
var id = "stream-id-to-update";
var newStreamName = "Updated Name"; // optional
var newDescription = "Updated Description"; // optional
var updatedStream = await _client.EditMessageStream(id, newStreamName, newDescription);
Console.WriteLine($"New Name: {updatedStream.Name}");
Console.WriteLine($"New Description: {updatedStream.Description}");
var archivalConfirmation = await _client.ArchiveMessageStream("stream-to-archive");
Console.WriteLine($"StreamID: {archivalConfirmation.ID}");
Console.WriteLine($"ServerID: {archivalConfirmation.ServerID}");
Console.WriteLine($"Expected Purge Date: {archivalConfirmation.ExpectedPurgeDate}");
Archiving a message stream will disable sending/receiving messages via that stream.
The stream will also stop being shown in the Postmark UI.
Once a stream has been archived, it will be deleted (alongside associated data) at the ExpectedPurgeDate
in the response.
var unarchivedStream = await _client.UnArchiveMessageStream("archived-stream-id");
Console.WriteLine($"StreamID: {unarchivedStream.ID}");
Console.WriteLine($"ServerID: {unarchivedStream.ServerID}");
UnArchiving a message stream will resume sending/receiving messages via that stream.
The stream will also re-appear in the Postmark UI.
A stream can be unarchived only before the stream's ExpectedPurgeDate
.
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