0

我的 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;
    }
4

2 回答 2

0

page.RenderControl() 或 control.RenderControl() 怎么样?

系统.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()

请转换成c#

于 2013-02-08T07:57:20.627 回答
0

你可以做这个把戏:

使 HTML 页面包含 Only<iframe>元素,它是source您希望在电子邮件中显示的页面

请记住,此技巧不适用于所有邮件提供商公司,在使用此技巧之前,您必须先检查它们的列表:http: //www.campaignmonitor.com/blog/post/3219/do-iframes -工作在电子邮件/

于 2013-02-08T08:05:10.437 回答