Embedding Images in Email

A feature of the Asp.Net 2.0 in the Emailing section is embedded images. With System.Net.Mail we can now embed images in the Emails sent from Asp.Net 2.0 web site.

To send an embedded image in the mail we first need to create an object of LinkedResource. This linkResource will actually contain the binary data of the Image. This binary data is then encoded as a part of the image and sent along as a part of the mail message.

We also need to give the LinkedResource a unique name and a content ID. We then create an HTML Alternate view. Inside that Html text we can use the standard img tag. The src attribute value will be the content Id of the linkedResource image. This is done by using the syntax The “src=cid:” part is required for the email client to recognize the tag as an embedded image, while the “whatever” part is the actual Content-Id of the LinkedResource image. This will instruct the mail client to find an embedded image named “whatever” and display the contents without making a http:// request.

That’s all there is to create a linked image.


~ by UTS on May 14, 2009.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: