我创建了一个 htmlTable,我想通过电子邮件发送它:
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)
当试图通过电子邮件发送tableAttributes
全局变量时......这就是我遇到麻烦的地方:
Message.Body = tableAttributes.anything
<-失败。
如何创建一个动态生成的表,然后通过电子邮件发送它?
**更新 - 提供了解决方案
哈哈!成功了,你真棒。这是我根据您的建议创建的:
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("*" & sTable & "*")