C# winforms: A problem with sending an email cointaining the image background
- by Tony
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 ?