<?xml-stylesheet type="text/css" href="http://www.mikepope.com/blog/rss/rssComments.css" ?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" >
  <channel>
    <title>System.Net.Mail and embedded images - Comments</title>
    <link>http://www.mikepope.com/blog/AddComment.aspx?blogid=1264</link>
    <description />
    <copyright>Copyright 2003-2007 Mike Pope </copyright>
    <dc:language>en-US</dc:language>
    <pubDate>Wed, 17 Aug 2005 16:28:41 GMT</pubDate>
    <generator>mike pope's Web log</generator>
    <webMaster>mike@mikepope.com</webMaster>
        <item>
      <title>Comment by Tman on "System.Net.Mail and embedded images"</title>
      <link></link>
      <guid>http://www.mikepope.com/blog/AddComment.aspx?blogid=1264#1264_1158</guid>
      <description>Thanx Mike!&lt;br&gt;Just great, hard to find good examples on this.</description>
      <dc:creator>Tman</dc:creator>
      <pubDate>Tue, 21 Feb 2006 05:21:56 GMT</pubDate>
    </item>
    <item>
      <title>Comment by kory s. on "System.Net.Mail and embedded images"</title>
      <link></link>
      <guid>http://www.mikepope.com/blog/AddComment.aspx?blogid=1264#1264_1240</guid>
      <description>Thanks! Your example was simple and straight forward, works perfectly.</description>
      <dc:creator>kory s.</dc:creator>
      <pubDate>Wed, 26 Apr 2006 13:40:42 GMT</pubDate>
    </item>
    <item>
      <title>Comment by Stephen on "System.Net.Mail and embedded images"</title>
      <link>http://www.morningz.com</link>
      <guid>http://www.mikepope.com/blog/AddComment.aspx?blogid=1264#1264_1376</guid>
      <description>Another thanks for this blog entry... much more detailed than anything out there i found (including www.systemnetmail.com's non-working example)</description>
      <dc:creator>Stephen</dc:creator>
      <pubDate>Thu, 17 Aug 2006 06:39:30 GMT</pubDate>
    </item>
    <item>
      <title>Comment by Dana Stephenson on "System.Net.Mail and embedded images"</title>
      <link></link>
      <guid>http://www.mikepope.com/blog/AddComment.aspx?blogid=1264#1264_1388</guid>
      <description>Great post, worked perfectly on the first try!  Thanks!</description>
      <dc:creator>Dana Stephenson</dc:creator>
      <pubDate>Wed, 30 Aug 2006 09:02:25 GMT</pubDate>
    </item>
    <item>
      <title>Comment by Kalesh on "System.Net.Mail and embedded images"</title>
      <link></link>
      <guid>http://www.mikepope.com/blog/AddComment.aspx?blogid=1264#1264_1462</guid>
      <description>Thanks mike for the article.&lt;br /&gt;I facing one issue....I am not able to access the class &lt;strong&gt;AlternateView &lt;/strong&gt; in my code..&lt;br /&gt;&lt;br /&gt;can u help me...I am using dotnet 2.0</description>
      <dc:creator>Kalesh</dc:creator>
      <pubDate>Thu, 26 Oct 2006 21:58:42 GMT</pubDate>
    </item>
    <item>
      <title>Comment by mike on "System.Net.Mail and embedded images"</title>
      <link>http://www.mikepope.com/blog/</link>
      <guid>http://www.mikepope.com/blog/AddComment.aspx?blogid=1264#1264_1463</guid>
      <description>Have you imported all the right namespaces? Probably you have, but thought it was worth asking.&lt;br /&gt;&lt;br /&gt;BTW, are you using Visual Studio? Do you see (for example) MailMessage but not AlternateView in IntelliSense?</description>
      <dc:creator>mike</dc:creator>
      <pubDate>Thu, 26 Oct 2006 22:58:17 GMT</pubDate>
    </item>
    <item>
      <title>Comment by Me on "System.Net.Mail and embedded images"</title>
      <link></link>
      <guid>http://www.mikepope.com/blog/AddComment.aspx?blogid=1264#1264_1477</guid>
      <description>So how would you do this thing in .NET 1.0?&lt;br /&gt;&lt;br /&gt;</description>
      <dc:creator>Me</dc:creator>
      <pubDate>Wed, 22 Nov 2006 20:07:04 GMT</pubDate>
    </item>
    <item>
      <title>Comment by mike on "System.Net.Mail and embedded images"</title>
      <link>http://www.mikepope.com/blog/</link>
      <guid>http://www.mikepope.com/blog/AddComment.aspx?blogid=1264#1264_1478</guid>
      <description>For 1.1, have a look at the discussion here:&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;a href=&quot;http://www.systemwebmail.com/faq/3.3.aspx&quot; target=&quot;_blank&quot;&gt;http://www.systemwebmail.com/faq/3.3.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Effectively, you can't do it natively with System.Web.Mail. There is a long thread of discussions in the comments that might be interesting.</description>
      <dc:creator>mike</dc:creator>
      <pubDate>Wed, 22 Nov 2006 21:03:37 GMT</pubDate>
    </item>
    <item>
      <title>Comment by Dan Clem on "System.Net.Mail and embedded images"</title>
      <link>http://www.electricstats.com</link>
      <guid>http://www.mikepope.com/blog/AddComment.aspx?blogid=1264#1264_1539</guid>
      <description>Thanks for posting this. You showed the correct way of doing something that the MSDN site was showing incorrectly:&lt;br /&gt;&lt;br /&gt;http://msdn2.microsoft.com/en-us/library/system.net.mail.mailmessage.alternateviews.aspx</description>
      <dc:creator>Dan Clem</dc:creator>
      <pubDate>Wed, 24 Jan 2007 14:09:49 GMT</pubDate>
    </item>
    <item>
      <title>Comment by Anonymous on "System.Net.Mail and embedded images"</title>
      <link></link>
      <guid>http://www.mikepope.com/blog/AddComment.aspx?blogid=1264#1264_1552</guid>
      <description>great! thanks!</description>
      <dc:creator>Anonymous</dc:creator>
      <pubDate>Wed, 07 Feb 2007 12:49:03 GMT</pubDate>
    </item>
    <item>
      <title>Comment by peter on "System.Net.Mail and embedded images"</title>
      <link></link>
      <guid>http://www.mikepope.com/blog/AddComment.aspx?blogid=1264#1264_1553</guid>
      <description>Also if you want to build the &lt;em&gt;email-sending-with-embedded-images&lt;/em&gt; functionality into a class library and include the jpg files into the DLL as embedded resources rather than referencing the files located in some web app:&lt;br /&gt;&lt;br /&gt;* add your jpegs to your class library project, mark their Build Action property as Embedded Resource&lt;br /&gt;* (say you've placed the &quot;emailheader.jpg&quot; image in the \EmbeddedImages\ folder inside your project)&lt;br /&gt;* than do this&lt;br /&gt;&lt;br /&gt;            string imgHeaderName = Assembly.GetExecutingAssembly().GetName().Name + &quot;.EmbeddedImages.emailheader.jpg&quot;;&lt;br /&gt;&lt;br /&gt;            Stream streamImageHeader = Assembly.GetExecutingAssembly().GetManifestResourceStream(imgHeaderName);&lt;br /&gt;&lt;br /&gt;            if (streamImageHeader != null)&lt;br /&gt;            {&lt;br /&gt;                LinkedResource lrImageHeader = new LinkedResource(streamImageHeader);&lt;br /&gt;                lrImageHeader.ContentId = CIDHEADER;&lt;br /&gt;                av.LinkedResources.Add(lrImageHeader);&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;where the av is the AlternateView object and CIDHEADER is the cid value from the email body.</description>
      <dc:creator>peter</dc:creator>
      <pubDate>Wed, 07 Feb 2007 15:20:05 GMT</pubDate>
    </item>
    <item>
      <title>Comment by longnguyen on "System.Net.Mail and embedded images"</title>
      <link></link>
      <guid>http://www.mikepope.com/blog/AddComment.aspx?blogid=1264#1264_1685</guid>
      <description>Public Function SendMailMessage(ByVal FromAddress As String, ByVal ToAddresses As String, ByVal Subject As String, ByVal Body As String, ByVal IsHTML As Boolean, ByVal ServerName As String, ByVal Port As Integer, ByVal UserName As String, ByVal PassWord As String) As Integer&lt;br /&gt;        Dim k As Integer = 0&lt;br /&gt;        Dim Message As New MailMessage&lt;br /&gt;        Dim smtp As New SmtpClient(ServerName, Port)&lt;br /&gt;        Message.From = New MailAddress(FromAddress)&lt;br /&gt;        Message.To.Add(ToAddresses)&lt;br /&gt;        Dim strMailContent As String&lt;br /&gt;        strMailContent = Body&lt;br /&gt;        &lt;br /&gt;                Dim av1 As AlternateView = AlternateView.CreateAlternateViewFromString(strMailContent, Nothing, &quot;Text/Html&quot;)&lt;br /&gt;              av1.TransferEncoding = Net.Mime.TransferEncoding.Base64&lt;br /&gt;        Message.AlternateViews.Add(av1)&lt;br /&gt;        Message.BodyEncoding = System.Text.Encoding.GetEncoding(&quot;utf-8&quot;) 'windows-1252&quot;) 'set the proper character set here&lt;br /&gt;        Message.Subject = Subject&lt;br /&gt;               Message.IsBodyHtml = IsHTML&lt;br /&gt;        Message.Priority = MailPriority.High&lt;br /&gt;                smtp.Credentials = New System.Net.NetworkCredential(Trim(UserName), Trim(PassWord))&lt;br /&gt;        &lt;br /&gt;        'smtp.EnableSsl = True&lt;br /&gt;        Try&lt;br /&gt;            smtp.Send(Message)&lt;br /&gt;            k = 1&lt;br /&gt;        Catch ex As Exception&lt;br /&gt;            k=0&lt;br /&gt;        End Try&lt;br /&gt;        SendMailMessage = k&lt;br /&gt;    End Function</description>
      <dc:creator>longnguyen</dc:creator>
      <pubDate>Thu, 14 Jun 2007 01:11:50 GMT</pubDate>
    </item>
    <item>
      <title>Comment by Gurpreet S Bakshi on "System.Net.Mail and embedded images"</title>
      <link></link>
      <guid>http://www.mikepope.com/blog/AddComment.aspx?blogid=1264#1264_1723</guid>
      <description>This is a great example. Works perfect where the case is to you an &amp;lt;IMG tag. Do you know a way to embed an image for a background-image property within the style of a particular element? &lt;br /&gt;&lt;br /&gt;&amp;lt;td style=&quot;background-image: url(Images/BlueExplorer.gif);&quot;&amp;gt;Some Text Here &lt;/td&gt;&lt;br /&gt;&lt;br /&gt;i have tried using Link resource and Alternate view the way you said and replaced the above URL text with cid:image1, but it doesn't seem to work. &lt;br /&gt;&lt;br /&gt;Any suggestions?&lt;br /&gt;&lt;br /&gt;</description>
      <dc:creator>Gurpreet S Bakshi</dc:creator>
      <pubDate>Fri, 20 Jul 2007 14:04:48 GMT</pubDate>
    </item>
    <item>
      <title>Comment by mat on "System.Net.Mail and embedded images"</title>
      <link></link>
      <guid>http://www.mikepope.com/blog/AddComment.aspx?blogid=1264#1264_1752</guid>
      <description>thx mike you saved the day!!!!</description>
      <dc:creator>mat</dc:creator>
      <pubDate>Tue, 14 Aug 2007 04:22:57 GMT</pubDate>
    </item>
    <item>
      <title>Comment by Charlie on "System.Net.Mail and embedded images"</title>
      <link></link>
      <guid>http://www.mikepope.com/blog/AddComment.aspx?blogid=1264#1264_1764</guid>
      <description>Mike,&lt;br /&gt;&lt;br /&gt;With outlook 2003 as the client this code works, but the image is still attached as a radomly named jpg and the html is also attached with another random name.&lt;br /&gt;&lt;br /&gt;How can i avoid having the .htm and .jpg files showing up at all?  Its quite important to my project that these don't show up.&lt;br /&gt;&lt;br /&gt;Hope you can help.</description>
      <dc:creator>Charlie</dc:creator>
      <pubDate>Mon, 20 Aug 2007 09:27:12 GMT</pubDate>
    </item>
    <item>
      <title>Comment by mike on "System.Net.Mail and embedded images"</title>
      <link>http://www.mikepope.com/blog/</link>
      <guid>http://www.mikepope.com/blog/AddComment.aspx?blogid=1264#1264_1765</guid>
      <description>@charlie -- I don't know what's wrong. I just tried it, and it worked perfectly in Outlook 2003. I can't help but think that it's some sort of configuration with the email client. If you send it to another client (e.g. gmail), perhaps it will work differently -- ?&lt;br /&gt;&lt;br /&gt;In any event, I'm going to advise that if that doesn't work, you post a query on the ASP.NET forums (&lt;a target='_blank' href='http://forums.asp.net).'&gt;http://forums.asp.net).&lt;/a&gt; Since I can't repro the problem, I'm afraid I can't really help debug it. :-(</description>
      <dc:creator>mike</dc:creator>
      <pubDate>Mon, 20 Aug 2007 11:13:04 GMT</pubDate>
    </item>
    <item>
      <title>Comment by MAnoj on "System.Net.Mail and embedded images"</title>
      <link></link>
      <guid>http://www.mikepope.com/blog/AddComment.aspx?blogid=1264#1264_1971</guid>
      <description>&lt;strong&gt;THANKS A LOT!!!&lt;br /&gt;EXATLY WHAT I WAS SEARCHING FOR...&lt;/strong&gt;</description>
      <dc:creator>MAnoj</dc:creator>
      <pubDate>Wed, 20 Feb 2008 00:47:34 GMT</pubDate>
    </item>

  </channel>
</rss>

