asked on
Dim errMessage As MailMessage
Dim body As String
Dim sb As New System.Text.StringBuilder
Dim dataTbl As New Data.DataTable
............
Dim r As DataRow
Dim count As Integer = 0
For Each r In dataTbl.Rows
count += 1
If count = 1 Then
sb.AppendLine("Number of customers who received an email: " & r("CountCol").ToString)
'body += "Number of customers who received an email: " & r("CountCol").ToString & vbCrLf & "<br>"
body = sb.ToString() & vbCrLf
End If
If count = 2 Then
sb.AppendLine("Number of email recipients: " & r("CountCol").ToString)
'body += " Number of email recipients: " & r("CountCol").ToString & vbCrLf & "<br>"
body = body & "Test" & vbCrLf
End If
If count = 3 Then
sb.AppendLine("Number of customers with invoices but no email address: " & r("CountCol").ToString)
'body += " Number of customers with invoices but no email address: " & r("CountCol").ToString & vbCrLf & "<br>"
End If
If count = 4 Then
sb.AppendLine("Number of customers with an invalid email address: " & r("CountCol").ToString)
'body += " Number of customers with an invalid email address: " & r("CountCol").ToString & vbCrLf & "<br>"
End If
Next
Dim errClient As SmtpClient
Dim errFrom As MailAddress
Dim errTo As MailAddress
errFrom = New MailAddress("n@field.com")
errTo = New MailAddress("ns@aero.com")
errMessage = New MailMessage(errFrom, errTo)
errMessage.Subject = "Errors in AR Statement"
errMessage.IsBodyHtml = True
errMessage.Body = sb.ToString()
'errMessage.Body = body
errClient = New SmtpClient(SMTPServer)
errClient.Credentials = Net.CredentialCache.DefaultNetworkCredentials
errClient.Send(errMessage)
Alternatively I have also tried to save the string in a string variable called "body"(you can see it commented out) and use vbCrLf or <br>, but it still does not work.
Visual Basic .NET (VB.NET) is an object-oriented programming language implemented on the .NET framework, but also supported on other platforms such as Mono and Silverlight. Microsoft launched VB.NET as the successor to the Visual Basic language. Though it is similar in syntax to Visual Basic pre-2002, it is not the same technology,
TRUSTED BY
ASKER
Great, your advice worked!
sb.AppendLine("Number of customers who received an email: " & r("CountCol").ToString & "<br><br>")
errMessage.Body = sb.ToString()