Results 1 to 3 of 3

Thread: including newline in string variable

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2013
    Posts
    4

    including newline in string variable

    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)

  2. #2
    Frenzied Member
    Join Date
    Feb 2008
    Location
    Texas
    Posts
    1,288

    Re: including newline in string variable

    You may have to append ControlChars.Lf (Line feed?) as well. If nothing else, just put the contents in a body tag, in an html tag and just use simple <br />
    You down with OOP? Yeah you know me!
    MCAD and MCMICKEYMOUSE (vb.net)

    ----

    If it even kinda helps... rate it : )

    Edit a Multi-page .tif file and save.

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2013
    Posts
    4

    Re: including newline in string variable

    Quote Originally Posted by MonkOFox View Post
    You may have to append ControlChars.Lf (Line feed?) as well. If nothing else, just put the contents in a body tag, in an html tag and just use simple <br />
    Doh! why didnt I just use the tags...

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width