Good Afternoon,

I am trying to move a gridview into a body of an email (using an html template) so I can email the gridview image as an HTML table. I've been able to response.write the gridview as a table to the top of my screen, but that's where I get lost on what to do next.

I've highlghted the parts where I am confused on how to finish building the body. If possible, I would also like to stop the screen from replacing the grid with the HTML grid.


Code:
Public Function Formatted_GridViewToHtml(ByVal grid As GridView) As String
        Dim sTringBuilder As New StringBuilder()
        Dim sTringWriter As New StringWriter(sTringBuilder)
        Dim hTmlTextWriter As New HtmlTextWriter(sTringWriter)

        grid.HeaderRow.Style.Add("background-color", "#FFFFFF")

        For Each tableCell As TableCell In grid.HeaderRow.Cells
            tableCell.Style("background-color") = "#A55129"
        Next

        For Each gridViewRow As GridViewRow In grid.Rows
            gridViewRow.BackColor = System.Drawing.Color.White
            For Each gridViewRowTableCell As TableCell In gridViewRow.Cells
                gridViewRowTableCell.Style("background-color") = "#FFF7E7"
            Next
        Next
        grid.RenderControl(hTmlTextWriter)
        Return sTringBuilder.ToString()
    End Function
    Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
        'This method will Confirms that an HtmlForm control is rendered for the specified ASP.NET server control at run time.
    End Sub
    Protected Sub HTMLGrid_Create()
        'Formatted_GridViewToHtml(GV_TicketNarrative)
        Response.Write(Formatted_GridViewToHtml(GV_TicketNarrative))
    End Sub
    Protected Sub HTML_Email()
        Dim Msg As New MailMessage()
        Dim body As String = File.ReadAllText(Server.MapPath("MailMessageTemplate_IT.htm"))

        'Dim Grid1 As String = Response.Write(Formatted_GridViewToHtml(GV_TicketNarrative))
        body = body.Replace("$ticket$", TicketNumber.Text)
        body = body.Replace("$Status$", TicketStatus.SelectedValue)
        body = body.Replace("$UsrName$", UserID.Text)
        body = body.Replace("$Location$", Department.Text)
        body = body.Replace("$DateCreated$", CreateDate.Text)
        body = body.Replace("$DateUpdated$", DateUpdated.Text)
        body = body.Replace("$ProblemNarrative$", ProblemShortDesc.Text)
        'body = body.Replace("$Gridview$", Grid1)
        Msg.Subject = "Test HTML"
        Msg.From = New MailAddress("test@test.com")
        Msg.To.Add(New MailAddress("test1@test.com"))
        Msg.IsBodyHtml = True
        Msg.Body = body
        Dim mSmtpClient As New SmtpClient()

        mSmtpClient.Send(Msg)
        Msg.Dispose() 'Clear memory

    End Sub