Why won't an embedded image show in html emails?

Posted on 2009-02-10
Last Modified: 2013-12-17
I'm looking to embed a header image into an HTML email generated by c#.  I've found code that is supposed to work, but the email arrives with the usual red x saying that it has no image.  (The same happens in Hotmail).  However, if I forward it, the attachment appears and so does the image.  Any ideas what might be going wrong?
if (EmailType == "ConfirmRegistration")


            message.IsBodyHtml = true;

            string contentId = "headerImage";

            string path = HttpContext.Current.Server.MapPath(@"img/Email/Header.jpg");

            LinkedResource header = new LinkedResource(path, MediaTypeNames.Image.Jpeg);

            header.ContentId = "header";

            AlternateView av1 = AlternateView.CreateAlternateViewFromString("<html xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns=\"urn:schemas-microsoft-com:office:office\" xmlnso=\"urn:schemas-microsoft-com:office:word\" xmlns:m=\"\" xmlns=\"\"><META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=us-ascii\"><body><img src=cid:header/><br></body></html>" + sEmailBody, null, MediaTypeNames.Text.Html);





Open in new window

Question by:mkingshott
    LVL 69

    Expert Comment

    by:Éric Moreau
    can you test if the example from is working for you (because it is for me)
    LVL 26

    Accepted Solution


    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    Suggested Solutions

    Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
    This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now