我的aspx页面包含一些下拉菜单和图表,当我尝试发送它时,它工作正常,但收到的电子邮件中它不包括图表和选定的下拉项目。请帮助我
这是我的代码..
protected void Button1_Click(object sender, EventArgs e)
{
//create the mail message
MailMessage mail = new MailMessage();
//set the addresses
mail.From = new MailAddress("vprajapat@nvidia.com");
mail.To.Add("vprajapat@nvidia.com");
//set the content
mail.Subject = "This is an email";
//screen scrape the html
string html = ScreenScrapeHtml("http://localhost:60275/WebSite5/Default2.aspx");
mail.Body = html;
mail.IsBodyHtml = true;
//send the message
SmtpClient smtp = new SmtpClient("smtp.nvidia.com", 25);
//smtp.EnableSsl = true;
smtp.UseDefaultCredentials = true;
smtp.Send(mail);
}
public static string ScreenScrapeHtml(string url)
{
WebRequest objRequest = System.Net.HttpWebRequest.Create(url);
StreamReader sr = new StreamReader(objRequest.GetResponse().GetResponseStream());
string result = sr.ReadToEnd();
sr.Close();
return result;
}
答案 0 :(得分:0)
page.RenderControl()或control.RenderControl()..?
的System.Web.UI
Dim sb As New StringBuilder()
Dim sw As New StringWriter(sb)
Dim htw As New HtmlTextWriter(sw)
gridview.RenderControl(htw) // or (control you wish)
Dim str As String = sb.ToString()
plz转换为c#
答案 1 :(得分:0)
你可能会这样做:
使HTML页面仅包含<iframe>
元素,并且source
您希望在电子邮件中显示的页面
请记住,此技巧不适用于所有邮件提供商公司,有一个列表,您必须先检查它们才能使用此技巧:http://www.campaignmonitor.com/blog/post/3219/do-iframes-work-in-email/