-
Notifications
You must be signed in to change notification settings - Fork 48
Sending Inline Images
Andrew Theken edited this page Dec 11, 2014
·
6 revisions
Sending inline images is simple with the Postmark library and is fully supported by the API.
In this example we want to send the bacon.jpg
file, inline with our message:
var message = new PostmarkMessage
{
From = "[email protected]",
To = "[email protected]",
Subject = "Inline Images",
HtmlBody = "<html><body><img src=\"cid:bacon.jpg\"></body></html>"
};
message.AddAttachment(@"c:\temp\bacon.jpg", "image/jpeg", "bacon.jpg");
var client = new PostmarkClient("SERVER_TOKEN");
var responses = client.SendMessage(message);
To do this, we took two steps:
- Add a
src
attribute to our image with thecid:
prefix to the file name we want to use for the attachement. - Include the file name when adding the attachment to the message
"bacon.jpg"
Technically, the "file name" above is the "Content ID" associated with the attachment, but using the file name is recommended.
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