从服务器端保存/发送ASP.NET页 [英] Save/Send a ASP.NET Page from the Server Side

查看:93
本文介绍了从服务器端保存/发送ASP.NET页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要实现的目标是从服务器通过电子邮件发送ASP.NET页面
边.该页面必须是最终结果,即所有服务器
控件已解决,只有纯HTML.我想
第一步是将结果HTML保存到文件中.有没有
外面有人知道该怎么做吗?由于这需要一个
自动过程.因此,它需要在服务器端完成.
任何建议将不胜感激.

What I am trying to achieve is to email an ASP.NET page from the server
side. The page needs to be in its final result, meaning all server
controls have been resolved and there''s only straight HTML. I suppose
that the first step is to save the result HTML to a file. Is there
someone out there knows how to do this? Since this needs to be an
automatic process. Therefore, it needs to be done on the server side.
Any suggestion will be highly appreciated.

推荐答案

使用此代码获取为页面生成的HTML

Use this code to get the HTML generated for the page

protected override void Render(HtmlTextWriter output)
{
StringWriter sw;
HtmlTextWriter htmltw;
sw = new StringWriter();
htmltw = new HtmlTextWriter(sw);
base.Render(htmltw);
StringBuilder temp = sw.GetStringBuilder();
// here do whatever you like with temp
base.Render(output);
}



然后,您可以使用MailMessage类对象通过电子邮件发送电子邮件.



Then you can email it using the MailMessage class object.


这篇关于从服务器端保存/发送ASP.NET页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆