Send a table in email

前端 未结 4 1228
一生所求
一生所求 2020-12-29 15:02

I have a requirement to send the results of a query in emails. I am using two methods:

GetDataTable() : to execute the query and obtain datatable(wh

4条回答
  •  暖寄归人
    2020-12-29 15:06

    In the past, I've made an object EmailGrid.cs which inherits from GridView. Then used a method like below to render the HTML into a string.

      public string RenderControl()
            {
                StringBuilder stringBuilder = new StringBuilder();
                StringWriter stringWriter = new StringWriter(stringBuilder);
                HtmlTextWriter htmlTextWriter = new HtmlTextWriter(stringWriter);
                RenderControl(htmlTextWriter);
    
                return stringBuilder.ToString();
            }
    

提交回复
热议问题