title: how to email a dynamically created htmltable - vb.net
body: <p>I have created an htmlTable and I want to email it:  </p>
  
  <pre><code>Dim MyRow As New HtmlTableRow  
  Dim cellCost, cellDisplayName, cellMoreInfo As New HtmlTableCell  
  Dim tableAttributes As New HtmlTable  
  tableAttributes.ID = "test"  
  
  cellCost.InnerText = "$45.00"  
  cellDisplayName.InnerText = "I am display Name"  
  cellMoreInfo.InnerText = "I am more information"  
  
  MyRow.Cells.Add(cellCost)  
  MyRow.Cells.Add(cellDisplayName)  
  MyRow.Cells.Add(cellMoreInfo)  
  
  tableAttributes.Rows.Add(MyRow)  
  
  PlaceHolder1.Controls.Add(tableAttributes)  
  </code></pre>
  
  <p>When trying to email the <code>tableAttributes</code> global variable ... well that's where I run into troubles:<br>
  <code>Message.Body = tableAttributes.anything</code> &lt;- fails.<br>
      How can I create a dynamically generated table and then email it?</p>
  
  <p>**UPDATE - solution was provided<br>
  Ha ha! it worked, you're awesome. This is what I created from your advice:    </p>
  
  <pre><code>Dim SB As New StringBuilder()  
  Dim SW As New StringWriter(SB)  
  Dim htmlTW As New HtmlTextWriter(SW)  
  Dim x As New HtmlTable  
  x = Session("table")  
  x.RenderControl(htmlTW)  
  
  Dim sTable As String = SB.ToString()  
  
  Response.Write("*" &amp; sTable &amp; "*") 
  </code></pre>