Sending aspx page with gridviews as email

后端 未结 3 767
情歌与酒
情歌与酒 2021-01-26 17:35

I was handed a new requirement and this one is new to me. After a day or two of research, I\'m still unable to figure this one out. The requirement is to find a way to send our

相关标签:
3条回答
  • 2021-01-26 18:09

    You will not be able to send any 'asp' code in an email and have it displayed correctly at the other end, you need a webserver in order to translate the asp code to the readable format on the screen.

    Your idea about having a separate, unsecured page is spot on.

    Another idea would be to 'print' the html to an image and send this.

    Another option would be to generate a page that outputs html that is compatible with email clients and email this as the body.

    0 讨论(0)
  • 2021-01-26 18:14

    Please do like this

    Msg.Body += GetGridviewData(gvUserInfo);
    

    function to convert gridview data

     // This Method is used to render gridview control
    public string GetGridviewData(GridView gv)
    {
         StringBuilder strBuilder = new StringBuilder();
         StringWriter strWriter = new StringWriter(strBuilder);
         HtmlTextWriter htw = new HtmlTextWriter(strWriter);
         gv.RenderControl(htw);
         return strBuilder.ToString();
    }
    
    0 讨论(0)
  • 2021-01-26 18:16

    Why not use a tool such as wkhtmltopdf c# wrapper or EvoPDF to convert the page to PDF and email as an attachment?

    Please note: The wkhtmltopdf c# library is free whereas the EvoPDF is unfortunately a commercial product.

    0 讨论(0)
提交回复
热议问题