470,816 Members | 1,200 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,816 developers. It's quick & easy.

Send email with html body using System.net.mail

Now i am sending email to my friend using session variable...

but my code is as below

private bool SendEmail(string email)



using (MailMessage mail = new MailMessage())

string msgBody="";
string message = "";

//Load the template page for the email template.

BlogEngine.Core.Page page2 = BlogEngine.Core.Page.GetPage(new
Guid(Session["Content"].ToString() ));
//Take the link for the main content page and add it to the content.
Use HTML breaks.

msgBody = page2.AbsoluteLink + "<br/>";msgBody += page2.Content + "<br/

//Take the content for the email heading intro message. This is hard
coded guid for the virtual page in the admin we created for sending
the email

BlogEngine.Core.Page page = BlogEngine.Core.Page.GetPage(new
message = page.Content;

// Add the 911 intro

msgBody = message + "<br/>" + msgBody;
//Email is from 911

mail.From = new MailAddress(BlogSettings.Instance.Email);
//This should add fields from the form for the user's name and thier

MailAddress ma = new MailAddress(this.txtTo.Text,

mail.Subject = page.Title;

//page content includes html

mail.IsBodyHtml = true;
//mail.BodyFormat = System.Web.Mail.MailFormat.Html;

// AlternateView PlainView =
AlternateView.CreateAlternateViewFromString("This is my Plain text
Content, Viewable by those client that dont support html", null, "text/

//AlternateView htmlView =
AlternateView.CreateAlternateViewFromString("<b>th is is bold text, and
Viewable by those client that support html </b>", null, "text/html");



mail.Body = msgBody;

//mail.BodyEncoding = System.Text.Encoding.UTF8;

//mail.BodyEncoding.IsBrowserSave = true;

//mail.Body = msgBody;


return true;

catch (Exception ex)

if (User.Identity.IsAuthenticated)

if (ex.InnerException != null)
lblStatus.Text = ex.InnerException.Message;


lblStatus.Text = ex.Message;


return false;


eventhogh i did mail.Isbodyhtml = true....

my email shows html tags in it i dont need that...how can i get that
do u hav any idea?
Nov 6 '08 #1
0 1971

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by James Hong | last post: by
5 posts views Thread by nate heaton | last post: by
3 posts views Thread by Frank | last post: by
2 posts views Thread by Malli mindwave | last post: by
3 posts views Thread by anu b | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.