views:

330

answers:

2

Hi, I'm trying to figure out how to resolve the problem:

I create the MailMessage object like that and send it:

        MailMessage mail = new MailMessage();

        mail.From = new MailAddress("[email protected]");
        mail.To.Add("[email protected]");

        mail.Subject = "This is an email";
        AlternateView plainView = AlternateView.CreateAlternateViewFromString("This is my plain text content, viewable by those clients that don't support html", null, MediaTypeNames.Text.Plain);


  (1)   AlternateView htmlView = AlternateView.CreateAlternateViewFromString("Here is an embedded image.<img src=cid:companylogo>", null, "text/html");

        LinkedResource logo = new LinkedResource("c:\\cop1.jpg");
        logo.ContentId = "companylogo";

        htmlView.LinkedResources.Add(logo);

        mail.AlternateViews.Add(plainView);
        mail.AlternateViews.Add(htmlView);

Everything is OK, the mail has the image in the background. But the problem is, when I change in the paragraph (1) from (click) to (click) everything fails, the image is not recognized and is threated as a attachment !

I think that is caused by the first colon here background-image:cid:companylogo

Is it possible to resolve that ?

+1  A: 

Change it to background-image:url("cid:companylogo").

SLaks
I tried, it doesn't work
Tony
Try adding quotes.
SLaks
the result is the same. I even tried to use (but I shouldn't) <body background="cid:companylogo"></body> with no result
Tony
+1  A: 

Hi,

You didn't say what mail client you are viewing this in. Not all mail clients support STYLE or CSS embedded images.

Here is a link regarding CSS support in mail clients: http://www.campaignmonitor.com/css/

Cheers!

Dave

dave wanta