I am trying to send an email and the body of the message in a certain format. Now if I create a table and populate it I get the format I want for that. But for a simple email where the body contains a simple string with multiple lines, I am not sure why it does does not work. I would like to know if this is an outlook issue or my code is incorrect. If I display the same thing in the console window it works.
Code:
Dim message As String = Environment.NewLine & "******************************************************" & Environment.NewLine & "PROCESSES STILL RUNNING!" & Environment.NewLine & "******************************************************" & Environment.NewLine
Console.WriteLine(message)
this works with both vbnewline and the above in the console window but not in the email viewed in outlook.
Code:
Sub MSGReporting(ByVal errorMessage As String)
Dim mail As New MailMessage()
mail.From = New MailAddress(fromEmail, "**PROCESS MANAGER**")
mail.Subject = "ADMIN ALERT"
mail.To.Add(adminEmail)
mail.IsBodyHtml = True
mail.Body = errorMessage
smptpServer.Send(mail)
End Sub
Here is the table code:
Code:
strB.Append("<table border=1 cellspacing=1 cellpadding=1><thead>")
For colIndx As Integer = 0 To dt.Columns.Count - 1
strB.Append("<th>")
strB.Append(dt.Columns(colIndx).ColumnName)
strB.Append("</th>")
Next
strB.Append("</thead>")
'add data rows to html table
For rowIndx As Integer = 0 To dt.Rows.Count - 1
strB.Append("<tr>")
For colIndx As Integer = 0 To dt.Columns.Count - 1
strB.Append("<td>")
strB.Append(dt.Rows(rowIndx)(colIndx).ToString())
strB.Append("</td>")
Next
strB.Append("</tr>")
Next
strB.Append("</table>")
MSGReporting(strB.ToString)