Embedded images on email

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Nov 2007
Posts: 28
Reputation: sniper1983 is an unknown quantity at this point 
Solved Threads: 0
sniper1983 sniper1983 is offline Offline
Light Poster

Embedded images on email

 
0
  #1
Jul 28th, 2009
Hi.

I have a problem when trying to embed pictures to an email. It works fine on windows server and the email is shown correct but when I try to put it in production which runs on Linux (mono 2.4) it sends the pictures as attachments (and deletes the first one of them.). I have tried alot and have searched everywhere but with no luck.

The code below works fine in windows but attach the embedded pictures in mono. Any surgestions what I can try, I'm running out of idears.

  1.  
  2. mail.BodyEncoding = System.Text.Encoding.UTF8;
  3. //AddSignature(ref pBodyPlain);
  4. string mBodyHtmlBn = "";
  5. mBodyHtmlBn += "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">";
  6. mBodyHtmlBn += "<HTML><HEAD><META http-equiv=Content-Type content=\"text/html; \"> </HEAD> ";
  7. mBodyHtmlBn += "<body bgcolor=\"#EEEEEE\">";
  8. mBodyHtmlBn += "<table bgcolor=\"#FFFFFF\" border=\"1\" cellpadding=\"8\" bordercolor=\"#CCCCCC\" width=\"500\">";
  9. mBodyHtmlBn += "<tr><td bgcolor=\"B2C6D9\"><img src='cid:header_left' align=\"left\"> <img src='cid:header_right' align=\"right\"></td></tr>";
  10. mBodyHtmlBn += "<tr><td>";
  11. mBodyHtmlBn += "<font face=\"verdana, arial\" size=\"2\">";
  12. mBodyHtmlBn += pBodyHtml;
  13. mBodyHtmlBn += "</font>";
  14. mBodyHtmlBn += "<img src='cid:logo_bottom' align=\"right\">";
  15. mBodyHtmlBn += "<br><br>";
  16. mBodyHtmlBn += "</td></tr></table>";
  17. mBodyHtmlBn += "</body></HTML>";
  18.  
  19. // PLAIN / HTML
  20. //System.Net.Mail.AlternateView plainView = System.Net.Mail.AlternateView.CreateAlternateViewFromString(pBodyPlain, null, "text/plain");
  21. System.Net.Mail.AlternateView htmlView = System.Net.Mail.AlternateView.CreateAlternateViewFromString(mBodyHtmlBn, new System.Net.Mime.ContentType("text/html")); //multipart/mixed")); //, null, "text/html");
  22.  
  23. System.Net.Mail.LinkedResource logo = new System.Net.Mail.LinkedResource(System.AppDomain.CurrentDomain.BaseDirectory + "/images/mailheader_newsletter.gif"); // + sHeaderImg);
  24. logo.ContentId = "header_left";
  25. //add the LinkedResource to the appropriate view
  26. htmlView.LinkedResources.Add(logo);
  27.  
  28. System.Net.Mail.LinkedResource logo2 = new System.Net.Mail.LinkedResource(System.AppDomain.CurrentDomain.BaseDirectory + "/images/mail_logo.gif", "image/gif");
  29. logo2.ContentId = "header_right";
  30. //add the LinkedResource to the appropriate view
  31. htmlView.LinkedResources.Add(logo2);
  32.  
  33. System.Net.Mail.LinkedResource logo3 = new System.Net.Mail.LinkedResource(System.AppDomain.CurrentDomain.BaseDirectory + "/images/mail_logo_bottom.gif", "image/gif");
  34. logo3.ContentId = "logo_bottom";
  35. //add the LinkedResource to the appropriate view
  36. htmlView.LinkedResources.Add(logo3);
  37.  
  38. mail.AlternateViews.Add(htmlView);
  39.  
  40. mail.Body = mBodyHtmlBn;
  41. System.Net.Mail.SmtpClient mSmtpClient = new System.Net.Mail.SmtpClient(Config.GetString("SMTP"));
  42.  
  43. //mail.IsBodyHtml = true;
  44. mSmtpClient.Send(mail);
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC