system.net.mail class question
thanks in advance
thanks in advance
Gagnar,
You have to use AlternateView to use LinkedResources. Instead of Message.Body, you can create a AlternateView (to which you add LinkedResources) and then add it to Message.AlternateView
Sample code is
//SET FROM, TO MailMessage Message = new MailMessage("<from>", "<TO>"); //SET SUBJECTMessage.Subject = "System.Net.Mail is easy"; //LINKED RESOURCESLinkedResource expresssql = new LinkedResource("expresssql.jpg", "image/jpeg");expresssql.ContentLink = new Uri("http://lab.msdn.microsoft.com/vs2005/art/expresssql.jpg");LinkedResource expressvb = new LinkedResource("expressvb.jpg", "image/jpeg");expressvb.ContentLink = new Uri("http://lab.msdn.microsoft.com/vs2005/art/expressvb.jpg");LinkedResource expressvcplusplus = new LinkedResource("expressvcplusplus.jpg", "image/jpeg");expressvcplusplus.ContentLink = new Uri("http://lab.msdn.microsoft.com/vs2005/art/expressvcplusplus.jpg");LinkedResource expressvcsharp = new LinkedResource("expressvcsharp.jpg", "image/jpeg");expressvcsharp.ContentLink = new Uri("http://lab.msdn.microsoft.com/vs2005/art/expressvcsharp.jpg");LinkedResource expressvjsharp = new LinkedResource("expressvjsharp.jpg", "image/jpeg");expressvjsharp.ContentLink = new Uri("http://lab.msdn.microsoft.com/vs2005/art/expressvjsharp.jpg");LinkedResource expressvwd = new LinkedResource("expressvwd.jpg", "image/jpeg");expressvwd.ContentLink = new Uri("http://lab.msdn.microsoft.com/vs2005/art/expressvwd.jpg"); //ADD Linked ResourcesAlternateView htmlBody = new AlternateView("VS2005.htm", "text/html");htmlBody.LinkedResources.Add(expresssql); htmlBody.LinkedResources.Add(expressvb); htmlBody.LinkedResources.Add(expressvcplusplus); htmlBody.LinkedResources.Add(expressvcsharp); htmlBody.LinkedResources.Add(expressvjsharp); htmlBody.LinkedResources.Add(expressvwd); //Add it to the MessageMessage.AlternateViews.Add(htmlBody); |
I've tried this. I don't get any errors, but when I receive the e-mail it is not like in the html file. The pictures are attached in the mail, but i cannot see the e-mail like the html file. Why is that?
Thanks