More Group Sites
Education Books
School Rankings
Jobless Net
Better Home
Enviro++
更好教育论坛


Help | Subscribe/Unsubscribe | Rules | Other Group Sites: Better Education | Better Education Forum
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Share
Options
View
Go to last post Go to first unread
hong  
#1 Posted : Sunday, 12 April 2009 3:35:03 AM(UTC)
hong

Rank: Administration

Reputation:

Groups: AcademicCoachingSchool, admin, Administration, BookSeller, CatholicSchool, CoachingAdult, CoachingProfessional, CoachingSports, ExtraCurriculumCoaching, IndependentSchool, Moderator, MusicTeacher, PrivateSchool, PublicSchool, SelectiveSchool, tutor
Joined: 23/11/2008(UTC)
Posts: 520

How to send an email in html and write Html tags in an email body?

How to send an email in html?
1.
Code:
MailMessage myMail = new MailMessage();
myMail.BodyFormat = MailFormat.Html;
string strBody = "<html><body><b>Hello World</b>" +
   " <font color=\"red\">c# - send an email in html</font></body></html>";

2.
Code:
MailMessage myMail = new MailMessage();
myMail.IsBodyHtml = true;
string strBody = "<b>Hello World</b>" +
   " <font color=\"red\">c# - send an email in html</font>";


How to write Html tags in an email body?
Write all the html text in string format, eg.
Code:
string strBody="<table><tr><td>hello</td></tr></table>";


Another example:
Code:
MailMessage myMail = new MailMessage();
myMail.BodyFormat = MailFormat.Html;
System.Text.StringBuildersb = new System.Text.StringBuilder();
System.Web.Mail.MailMessage mail = new System.Mail.Web.MailMessage(); 
sb.Append("<html><head><title>Hello World</title><body>");
sb.Append("<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">");
sb.Append("<tr><td>");
sb.Append("<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">");
sb.Append("<tr><td style=\"FONT-SIZE: 12pt;COLOR: blue; FONT-FAMILY: Arial, Monospace; \">Header</td></tr></table>");
sb.Append("</td></tr>");
sb.Append("<tr><td>");
sb.Append("Body");
sb.Append("</td></tr>");
sb.Append("<tr><td>");
sb.Append("Footer");
sb.Append("</td></tr></table>");
sb.Append("</body></html>");
myMail.Body = sb.ToString();
Sponsor
Rss Feed  Atom Feed
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.