I have a program that on load will load the dataset with info from a query. I then send the information in an email. Everything is working correctly except the output. The output is wrapped and not in table format. If I debug the program and paste the “Value” of “Payouts” into a txt document and save it as an html file it is formatted correctly (Shows in table form). Here is my Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Dim SmtpServer As New SmtpClient()
Dim mail As New MailMessage()
Me.Paid_Out_TbTableAdapter.Fill(Me.DataDeliveryServiceDataSet.Paid_Out_Tb)
Dim payouts = _
<html>
<body>
<table>
<tr><th>My First Column Header</th><th>My Second Column Header</th></tr>
<%= From paidOut In Me.DataDeliveryServiceDataSet.Paid_Out_Tb.AsEnumerable _
Select <tr><td><%= paidOut.Store_Id %></td><td><%= paidOut.Paid_Out_Comment %></td></tr> %>
</table>
</body>
</html>
SmtpServer.Credentials = New _
Net.NetworkCredential("****", "****")
SmtpServer.Port = 25
SmtpServer.Host = "*****"
mail = New MailMessage()
mail.From = New MailAddress("*@*.com")
mail.To.Add("*@*.com")
mail.Subject = "Test Mail"
mail.IsBodyHtml = True
mail.Body = payouts
SmtpServer.Send(mail)
MsgBox("mail send")
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Here what is sent in an email as the body:
My First Column HeaderMy Second Column Header4567OFFICE SUPPLIES4567REIMBUSEMENT FOR SERVICE PER ROB PER INCIDENT REPORT4567REFUND FOR SERVICE INVOICE# **4567OFFICE SUPPLIES AND GATORADE
As you can see it’s just wrapped and not formatted… How can I get the body to be either in TXT format as a table, or in HTML Format as a table.
The
CStr(XElement)function just returns the content of the element. Use: