<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: ASP.NET &#8211; Sending Email Both in HTML and Plain Text</title>
	<atom:link href="http://www.search-this.com/2009/02/05/aspnet-sending-email-both-in-html-and-plain-text/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.search-this.com/2009/02/05/aspnet-sending-email-both-in-html-and-plain-text/</link>
	<description>Internet Marketing, Website Promotion and Blogging Advice</description>
	<lastBuildDate>Sun, 29 Jan 2012 02:18:27 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Ranjithprasad</title>
		<link>http://www.search-this.com/2009/02/05/aspnet-sending-email-both-in-html-and-plain-text/comment-page-1/#comment-227782</link>
		<dc:creator>Ranjithprasad</dc:creator>
		<pubDate>Mon, 01 Aug 2011 16:33:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.search-this.com/?p=804#comment-227782</guid>
		<description>using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail ;

namespace mail
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            MailDefinition message = new MailDefinition();
            System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
            msg.To.Add(&quot;To_mail@gmail.com&quot;);

            
            msg.From = new MailAddress(&quot;From_mail@gmail.com&quot;, &quot;&quot;, System.Text.Encoding.UTF8);

            msg.Subject = &quot;That&#039;s Your Password&quot;;
            msg.SubjectEncoding = System.Text.Encoding.UTF8;

            msg.Body = &quot;asd123y&quot;;
          
            msg.BodyEncoding = System.Text.Encoding.UTF8;

            msg.IsBodyHtml = false;
            msg.Priority = MailPriority.High;

            SmtpClient client = new SmtpClient();
            client.Credentials = new System.Net.NetworkCredential(&quot;yourmail_id@gmail.com&quot;, &quot;your_password&quot;);
            client.Port = 587;

            client.Host = &quot;smtp.gmail.com&quot;;
            client.EnableSsl = true;

            client.Send(msg);

        }
    }
}</description>
		<content:encoded><![CDATA[<p>using System;<br />
using System.Collections.Generic;<br />
using System.Linq;<br />
using System.Web;<br />
using System.Web.UI;<br />
using System.Web.UI.WebControls;<br />
using System.Net.Mail ;</p>
<p>namespace mail<br />
{<br />
    public partial class _Default : System.Web.UI.Page<br />
    {<br />
        protected void Page_Load(object sender, EventArgs e)<br />
        {</p>
<p>        }</p>
<p>        protected void Button1_Click(object sender, EventArgs e)<br />
        {<br />
            MailDefinition message = new MailDefinition();<br />
            System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();<br />
            msg.To.Add(&#8220;To_mail@gmail.com&#8221;);</p>
<p>            msg.From = new MailAddress(&#8220;From_mail@gmail.com&#8221;, &#8220;&#8221;, System.Text.Encoding.UTF8);</p>
<p>            msg.Subject = &#8220;That&#8217;s Your Password&#8221;;<br />
            msg.SubjectEncoding = System.Text.Encoding.UTF8;</p>
<p>            msg.Body = &#8220;asd123y&#8221;;</p>
<p>            msg.BodyEncoding = System.Text.Encoding.UTF8;</p>
<p>            msg.IsBodyHtml = false;<br />
            msg.Priority = MailPriority.High;</p>
<p>            SmtpClient client = new SmtpClient();<br />
            client.Credentials = new System.Net.NetworkCredential(&#8220;yourmail_id@gmail.com&#8221;, &#8220;your_password&#8221;);<br />
            client.Port = 587;</p>
<p>            client.Host = &#8220;smtp.gmail.com&#8221;;<br />
            client.EnableSsl = true;</p>
<p>            client.Send(msg);</p>
<p>        }<br />
    }<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: michael</title>
		<link>http://www.search-this.com/2009/02/05/aspnet-sending-email-both-in-html-and-plain-text/comment-page-1/#comment-198108</link>
		<dc:creator>michael</dc:creator>
		<pubDate>Mon, 14 Mar 2011 11:28:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.search-this.com/?p=804#comment-198108</guid>
		<description>Use MailMessage and SmtpClient class to build the sending mail program.
I already answered in other website. See the below link :

http://www.hyperneed.com/ShowSearchAnswers.aspx?searchstring=&amp;category=Programming&amp;questionid=b507b018-e456-4be6-b037-ec416c9eb712</description>
		<content:encoded><![CDATA[<p>Use MailMessage and SmtpClient class to build the sending mail program.<br />
I already answered in other website. See the below link :</p>
<p><a href="http://www.hyperneed.com/ShowSearchAnswers.aspx?searchstring=&#038;category=Programming&#038;questionid=b507b018-e456-4be6-b037-ec416c9eb712" rel="nofollow">http://www.hyperneed.com/ShowSearchAnswers.aspx?searchstring=&#038;category=Programming&#038;questionid=b507b018-e456-4be6-b037-ec416c9eb712</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John A Davis</title>
		<link>http://www.search-this.com/2009/02/05/aspnet-sending-email-both-in-html-and-plain-text/comment-page-1/#comment-186318</link>
		<dc:creator>John A Davis</dc:creator>
		<pubDate>Mon, 10 Jan 2011 05:09:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.search-this.com/?p=804#comment-186318</guid>
		<description>I&#039;m using an array list &quot;aPic&quot; that holds the picture locations. I guess this code isn&#039;t complete. The part I gave you works, but I can&#039;t look at the rest right now.</description>
		<content:encoded><![CDATA[<p>I&#8217;m using an array list &#8220;aPic&#8221; that holds the picture locations. I guess this code isn&#8217;t complete. The part I gave you works, but I can&#8217;t look at the rest right now.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John A Davis</title>
		<link>http://www.search-this.com/2009/02/05/aspnet-sending-email-both-in-html-and-plain-text/comment-page-1/#comment-186317</link>
		<dc:creator>John A Davis</dc:creator>
		<pubDate>Mon, 10 Jan 2011 05:07:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.search-this.com/?p=804#comment-186317</guid>
		<description>I don&#039;t have time to change it to C#, but I bet you could. Just paste it into your C# code and change the object declarations, etc.
Shouldn&#039;t really be that hard. VS will underline what is wrong. I use the code to send out 4 pictures shrunken in an email body.</description>
		<content:encoded><![CDATA[<p>I don&#8217;t have time to change it to C#, but I bet you could. Just paste it into your C# code and change the object declarations, etc.<br />
Shouldn&#8217;t really be that hard. VS will underline what is wrong. I use the code to send out 4 pictures shrunken in an email body.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Tippett</title>
		<link>http://www.search-this.com/2009/02/05/aspnet-sending-email-both-in-html-and-plain-text/comment-page-1/#comment-186196</link>
		<dc:creator>Michael Tippett</dc:creator>
		<pubDate>Sun, 09 Jan 2011 06:29:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.search-this.com/?p=804#comment-186196</guid>
		<description>is that the solution John?

any chance you know it in C#? My vb is very rusty</description>
		<content:encoded><![CDATA[<p>is that the solution John?</p>
<p>any chance you know it in C#? My vb is very rusty</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John A Davis</title>
		<link>http://www.search-this.com/2009/02/05/aspnet-sending-email-both-in-html-and-plain-text/comment-page-1/#comment-185988</link>
		<dc:creator>John A Davis</dc:creator>
		<pubDate>Fri, 07 Jan 2011 15:31:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.search-this.com/?p=804#comment-185988</guid>
		<description>Private Sub sSendInvoiceEmail(ByVal strHTMLBody As String)

		Dim avHtml As AlternateView = AlternateView.CreateAlternateViewFromString(strHTMLBody, Nothing, MediaTypeNames.Text.Html)
		&#039; Create a LinkedResource object for each embedded image


		Dim imageResource As LinkedResource
		&#039;For i As Integer = 0 To aPics.Count - 1
		&#039;	newBody = newBody.Replace(imageNVC.Get(i).ToString, &quot;cid:&quot; &amp; imageNVC.GetKey(i).ToString)
		&#039;Next

		&#039;htmlView = CreateHtmlView(newBody)	&#039; text/html

		For i As Integer = 0 To aPics.Count - 1

			imageResource = New LinkedResource(aPics(i).ToString(), MediaTypeNames.Image.Jpeg)
			imageResource.ContentId = &quot;Pic&quot; &amp; (i)
			&#039;imageResource.TransferEncoding = TransferEncoding.Base64
			avHtml.LinkedResources.Add(imageResource)

		Next




		Dim mail As New MailMessage

		mail.AlternateViews.Add(avHtml)

		mail.From = New System.Net.Mail.MailAddress(txtEmailFrom.Text)
		mail.To.Add(New System.Net.Mail.MailAddress(txtEmailTo.Text))
		mail.Subject = txtSubject.Text.ToString()
		mail.IsBodyHtml = True

		mail.Body = strHTMLBody</description>
		<content:encoded><![CDATA[<p>Private Sub sSendInvoiceEmail(ByVal strHTMLBody As String)</p>
<p>		Dim avHtml As AlternateView = AlternateView.CreateAlternateViewFromString(strHTMLBody, Nothing, MediaTypeNames.Text.Html)<br />
		&#8216; Create a LinkedResource object for each embedded image</p>
<p>		Dim imageResource As LinkedResource<br />
		&#8216;For i As Integer = 0 To aPics.Count &#8211; 1<br />
		&#8216;	newBody = newBody.Replace(imageNVC.Get(i).ToString, &#8220;cid:&#8221; &amp; imageNVC.GetKey(i).ToString)<br />
		&#8216;Next</p>
<p>		&#8216;htmlView = CreateHtmlView(newBody)	&#8216; text/html</p>
<p>		For i As Integer = 0 To aPics.Count &#8211; 1</p>
<p>			imageResource = New LinkedResource(aPics(i).ToString(), MediaTypeNames.Image.Jpeg)<br />
			imageResource.ContentId = &#8220;Pic&#8221; &amp; (i)<br />
			&#8216;imageResource.TransferEncoding = TransferEncoding.Base64<br />
			avHtml.LinkedResources.Add(imageResource)</p>
<p>		Next</p>
<p>		Dim mail As New MailMessage</p>
<p>		mail.AlternateViews.Add(avHtml)</p>
<p>		mail.From = New System.Net.Mail.MailAddress(txtEmailFrom.Text)<br />
		mail.To.Add(New System.Net.Mail.MailAddress(txtEmailTo.Text))<br />
		mail.Subject = txtSubject.Text.ToString()<br />
		mail.IsBodyHtml = True</p>
<p>		mail.Body = strHTMLBody</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael</title>
		<link>http://www.search-this.com/2009/02/05/aspnet-sending-email-both-in-html-and-plain-text/comment-page-1/#comment-185967</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Fri, 07 Jan 2011 12:36:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.search-this.com/?p=804#comment-185967</guid>
		<description>Blast. Ive been working on this for 5 hours straight now.

I get the same error as other people in this thread..

If i include the embeddedobject it just sends a blank email.

if i remove it. the email sends great. (although i neeeeeeeeed a embedded picture)

Any Ideas?</description>
		<content:encoded><![CDATA[<p>Blast. Ive been working on this for 5 hours straight now.</p>
<p>I get the same error as other people in this thread..</p>
<p>If i include the embeddedobject it just sends a blank email.</p>
<p>if i remove it. the email sends great. (although i neeeeeeeeed a embedded picture)</p>
<p>Any Ideas?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dvn of Mass</title>
		<link>http://www.search-this.com/2009/02/05/aspnet-sending-email-both-in-html-and-plain-text/comment-page-1/#comment-171513</link>
		<dc:creator>dvn of Mass</dc:creator>
		<pubDate>Wed, 11 Aug 2010 15:40:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.search-this.com/?p=804#comment-171513</guid>
		<description>I really enjoyed and learnt alot form your post. To epxand the topic further, i would like to know how would i implement the codes where i want to populate the content of the email dynamically when the user 
1. click to open the email
or 
2. click on a button inside the body of the email.
I would appreciate any comments or guide from any expert out there
Thank you and keep up the good post folks.</description>
		<content:encoded><![CDATA[<p>I really enjoyed and learnt alot form your post. To epxand the topic further, i would like to know how would i implement the codes where i want to populate the content of the email dynamically when the user<br />
1. click to open the email<br />
or<br />
2. click on a button inside the body of the email.<br />
I would appreciate any comments or guide from any expert out there<br />
Thank you and keep up the good post folks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve from MI</title>
		<link>http://www.search-this.com/2009/02/05/aspnet-sending-email-both-in-html-and-plain-text/comment-page-1/#comment-168250</link>
		<dc:creator>Steve from MI</dc:creator>
		<pubDate>Tue, 22 Jun 2010 01:48:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.search-this.com/?p=804#comment-168250</guid>
		<description>Unfortunately, this doesn&#039;t work at all for me because the .CreateMailMessage is requiring a Control to find the file, but this is running in an independent thread - so I get an error indicating that the basepath cannot be null.

Isn&#039;t there some way to give the full url to the html file instead of relying on the call to find it on its own from a control&#039;s basepath?</description>
		<content:encoded><![CDATA[<p>Unfortunately, this doesn&#8217;t work at all for me because the .CreateMailMessage is requiring a Control to find the file, but this is running in an independent thread &#8211; so I get an error indicating that the basepath cannot be null.</p>
<p>Isn&#8217;t there some way to give the full url to the html file instead of relying on the call to find it on its own from a control&#8217;s basepath?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John A Davis</title>
		<link>http://www.search-this.com/2009/02/05/aspnet-sending-email-both-in-html-and-plain-text/comment-page-1/#comment-166841</link>
		<dc:creator>John A Davis</dc:creator>
		<pubDate>Fri, 28 May 2010 21:14:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.search-this.com/?p=804#comment-166841</guid>
		<description>Just what I needed. I was wondering about the Alerternate View stuff since I KNOW some email programs don&#039;t display HTML

thank you!</description>
		<content:encoded><![CDATA[<p>Just what I needed. I was wondering about the Alerternate View stuff since I KNOW some email programs don&#8217;t display HTML</p>
<p>thank you!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lien</title>
		<link>http://www.search-this.com/2009/02/05/aspnet-sending-email-both-in-html-and-plain-text/comment-page-1/#comment-160470</link>
		<dc:creator>lien</dc:creator>
		<pubDate>Tue, 16 Feb 2010 21:45:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.search-this.com/?p=804#comment-160470</guid>
		<description>How do you get rid of the .dat attachment when you send mail as html?  Thoughts?</description>
		<content:encoded><![CDATA[<p>How do you get rid of the .dat attachment when you send mail as html?  Thoughts?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shalimar</title>
		<link>http://www.search-this.com/2009/02/05/aspnet-sending-email-both-in-html-and-plain-text/comment-page-1/#comment-159438</link>
		<dc:creator>shalimar</dc:creator>
		<pubDate>Sat, 30 Jan 2010 06:27:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.search-this.com/?p=804#comment-159438</guid>
		<description>I first thank you very much for this venture. But I would like to mention that I copied your code and tried to run it in visual studio. Mail is sending with out any content in body. I don&#039;t know why the content is not coming.

            I am very thankful if you send a downloadable copy of the working code is mailed to me.</description>
		<content:encoded><![CDATA[<p>I first thank you very much for this venture. But I would like to mention that I copied your code and tried to run it in visual studio. Mail is sending with out any content in body. I don&#8217;t know why the content is not coming.</p>
<p>            I am very thankful if you send a downloadable copy of the working code is mailed to me.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doris</title>
		<link>http://www.search-this.com/2009/02/05/aspnet-sending-email-both-in-html-and-plain-text/comment-page-1/#comment-159404</link>
		<dc:creator>Doris</dc:creator>
		<pubDate>Fri, 29 Jan 2010 20:03:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.search-this.com/?p=804#comment-159404</guid>
		<description>When I include the
EmbeddedMailObject the HTML message body is null.

But if I exclude it, everything works. I’ve double checked my paths. 

Any Ideas? Thanks</description>
		<content:encoded><![CDATA[<p>When I include the<br />
EmbeddedMailObject the HTML message body is null.</p>
<p>But if I exclude it, everything works. I’ve double checked my paths. </p>
<p>Any Ideas? Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kjetil Myhre</title>
		<link>http://www.search-this.com/2009/02/05/aspnet-sending-email-both-in-html-and-plain-text/comment-page-1/#comment-156288</link>
		<dc:creator>Kjetil Myhre</dc:creator>
		<pubDate>Wed, 25 Nov 2009 21:00:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.search-this.com/?p=804#comment-156288</guid>
		<description>Excellent walk-through! Just what I needed to keep going strong :)</description>
		<content:encoded><![CDATA[<p>Excellent walk-through! Just what I needed to keep going strong <img src='http://www.search-this.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: .NET Junkie</title>
		<link>http://www.search-this.com/2009/02/05/aspnet-sending-email-both-in-html-and-plain-text/comment-page-1/#comment-154973</link>
		<dc:creator>.NET Junkie</dc:creator>
		<pubDate>Fri, 06 Nov 2009 03:54:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.search-this.com/?p=804#comment-154973</guid>
		<description>Thanks for the code and explanation. It helped me out!</description>
		<content:encoded><![CDATA[<p>Thanks for the code and explanation. It helped me out!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

