| | |
Embedded images on email
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2007
Posts: 28
Reputation:
Solved Threads: 0
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.
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.
C# Syntax (Toggle Plain Text)
mail.BodyEncoding = System.Text.Encoding.UTF8; //AddSignature(ref pBodyPlain); string mBodyHtmlBn = ""; mBodyHtmlBn += "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">"; mBodyHtmlBn += "<HTML><HEAD><META http-equiv=Content-Type content=\"text/html; \"> </HEAD> "; mBodyHtmlBn += "<body bgcolor=\"#EEEEEE\">"; mBodyHtmlBn += "<table bgcolor=\"#FFFFFF\" border=\"1\" cellpadding=\"8\" bordercolor=\"#CCCCCC\" width=\"500\">"; mBodyHtmlBn += "<tr><td bgcolor=\"B2C6D9\"><img src='cid:header_left' align=\"left\"> <img src='cid:header_right' align=\"right\"></td></tr>"; mBodyHtmlBn += "<tr><td>"; mBodyHtmlBn += "<font face=\"verdana, arial\" size=\"2\">"; mBodyHtmlBn += pBodyHtml; mBodyHtmlBn += "</font>"; mBodyHtmlBn += "<img src='cid:logo_bottom' align=\"right\">"; mBodyHtmlBn += "<br><br>"; mBodyHtmlBn += "</td></tr></table>"; mBodyHtmlBn += "</body></HTML>"; // PLAIN / HTML //System.Net.Mail.AlternateView plainView = System.Net.Mail.AlternateView.CreateAlternateViewFromString(pBodyPlain, null, "text/plain"); System.Net.Mail.AlternateView htmlView = System.Net.Mail.AlternateView.CreateAlternateViewFromString(mBodyHtmlBn, new System.Net.Mime.ContentType("text/html")); //multipart/mixed")); //, null, "text/html"); System.Net.Mail.LinkedResource logo = new System.Net.Mail.LinkedResource(System.AppDomain.CurrentDomain.BaseDirectory + "/images/mailheader_newsletter.gif"); // + sHeaderImg); logo.ContentId = "header_left"; //add the LinkedResource to the appropriate view htmlView.LinkedResources.Add(logo); System.Net.Mail.LinkedResource logo2 = new System.Net.Mail.LinkedResource(System.AppDomain.CurrentDomain.BaseDirectory + "/images/mail_logo.gif", "image/gif"); logo2.ContentId = "header_right"; //add the LinkedResource to the appropriate view htmlView.LinkedResources.Add(logo2); System.Net.Mail.LinkedResource logo3 = new System.Net.Mail.LinkedResource(System.AppDomain.CurrentDomain.BaseDirectory + "/images/mail_logo_bottom.gif", "image/gif"); logo3.ContentId = "logo_bottom"; //add the LinkedResource to the appropriate view htmlView.LinkedResources.Add(logo3); mail.AlternateViews.Add(htmlView); mail.Body = mBodyHtmlBn; System.Net.Mail.SmtpClient mSmtpClient = new System.Net.Mail.SmtpClient(Config.GetString("SMTP")); //mail.IsBodyHtml = true; mSmtpClient.Send(mail);
![]() |
Similar Threads
- Sending an image to email via PHP form? (PHP)
- HMTL Email (HTML and CSS)
- c/c++ program to read rtf file's text in linux (C++)
- images uploaded to photobucket aren't showing up (Windows Vista and Windows 7)
- Outlook Won't Present Embedded Images (Windows Software)
- Trojan Horse/Hijack Recovery - Outlook (Windows NT / 2000 / XP)
- how to display an attached image file in email (ASP)
- Printing Embedded JComponents (Java)
Other Threads in the C# Forum
- Previous Thread: Is it possible create pivot table and copy to data table using c#.net?
- Next Thread: login window in main window
| Thread Tools | Search this Thread |
.net access algorithm array asp.net barchart bitmap box broadcast buttons c# check checkbox client combobox control conversion csharp custom database databaseconnection datagrid datagridview dataset datetime dbconnection degrees design development draganddrop drawing encryption enum event eventhandlers excel file firefox form format forms function gdi+ httpwebrequest image index input install java label libraries list listbox loop mandelbrot marshalbyrefobject math mouseclick movingimage mysql mysql.data.client operator path photoshop php picturebox pixelinversion post programming radians regex remote remoting resourcefile richtextbox server sleep socket sql statistics stream string study system.servicemodel table tcpclientchannel text textbox thread time timer update usercontrol validation visualstudio webbrowser windows winforms wpf xml





