Click here to Skip to main content
12,828,907 members (48,880 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


7 bookmarked
Posted 2 May 2013

How to Send Email Messages with Embedded Images

, 2 May 2013 MIT
Rate this:
Please Sign up or sign in to vote.
How to send email messages with embedded images.

While creating email messages with HTML content, normally the images are displayed with IMG tag, where the SRC attribute is pointing to an image, which is hosted in the web server. Most email clients will not display the images, which is downloading from the web. Instead of pointing to web URL, you can embed image in the mail message with the help of LinkedResource and AlternateView classes.

Here is the snippet, which embeds an image to the email. The convention to access linked resource is cid:name of the linked resource, which is the value of IMG tag SRC attribute.

var logo = new LinkedResource(@"C:\logo.jpg");
logo.ContentId = Guid.NewGuid().ToString();
var body = 
    <img src=""cid:{0}"" /></body></html>", 
var view = AlternateView.CreateAlternateViewFromString(body, null, "text/html");
using (var message = new MailMessage(fromAddress, toAddress)
    Subject = subject,
    Body = body,
    IsBodyHtml = true

Note: This method will increase the size of the email, as the images are embedded.

Related Content

  1. Fluent email library for C# using DynamicObject
  2. Uploading Files using Webservice
  3. Post data using HttpWebRequest in C#
  4. How to Store and Retrieve files from SQL Server Database
  5. Convert Image to Icon using C#


This article, along with any associated source code and files, is licensed under The MIT License


About the Author

Anuraj Parameswaran
Technical Lead
India India
Working as Tech. Lead

My blog :
You can follow me in twitter : @anuraj

You may also be interested in...

Comments and Discussions

Questionhi Pin
Member 1007103623-Jul-13 11:17
memberMember 1007103623-Jul-13 11:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170326.1 | Last Updated 2 May 2013
Article Copyright 2013 by Anuraj Parameswaran
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid