Extracted and converted original source by Scott Mitchell.
// You can render any ASP.NET control to pure HTML like this:
StringBuilder sb = new StringBuilder();StringWriter sw = new StringWriter(sb);HtmlTextWriter htmlTW = new HtmlTextWriter(sw);cControlToRender.RenderControl(htmlTW);string html = sb.ToString();
StringBuilder sb =
StringWriter sw =
HtmlTextWriter htmlTW =
cControlToRender.RenderControl(htmlTW);
string
// And use the output as the body of an HTML mail.
using System.Web.Mail;...MailMessage msg = new MailMessage();msg.To = "someone@dotnet-online.com";msg.From = "whoever@dotnet-online.com";msg.Subject = "ASP.NET Rendered HTML Mail";msg.BodyFormat = MailFormat.Html;msg.Body = html;...SmtpMail.Send(msg);
...
MailMessage msg =
msg.From = "whoever@dotnet-online.com";
msg.Subject = "ASP.NET Rendered HTML Mail";
msg.BodyFormat = MailFormat.Html;
msg.Body = html;
SmtpMail.Send(msg);
Related...
http://dotnetjunkies.com/WebLog/nenoloje/archive/2005/01/05/41654.aspx | Comments
posted on Thursday, January 06, 2005 7:19 AM