Use of vbNewLine and CHR(10) within HTML code

NewOrderFac33

Well-known Member
Joined
Sep 26, 2011
Messages
1,275
Office Version
  1. 2016
  2. 2010
Platform
  1. Windows
Good morning,

I am processing a list of entries in a database to generate an email.

Rich (BB code):
    DLLBody = ""
    MyCount = 1
    For Each MyCell In Sheets("Version3 DB").Range("V3_Col_DLLNames")
        DLLBody = DLLBody & Format(MyCount, "000") & " DLL Name: " & MyCell.Value & ", Product: " & MyCell.Offset(0, 1).Value & ", Configuration Item: " & MyCell.Offset(0, 1).Value & vbNewLine & vbNewLine
        MyCount = MyCount + 1
    Next
    
    StrBody = "<span style='font-size:12.0pt;font-family:Arial;color:black'><B><U>" & "Critical component DLL change" & " </B></U></span>"
    StrBody = StrBody & "<HTML><BR> <BR> <BR> "
    StrBody = StrBody & "<span style='font-size:10.0pt;font-family:Arial;color:black'>" & "Good morning," & "</span>"
    StrBody = StrBody & "<BR><BR> "
    StrBody = StrBody & "<span style='font-size:10.0pt;font-family:Arial;color:black'>" & "Please note that the latest version of the DLL Report reflects " & _
        "changes to the following critical components:" & "</span>"
    StrBody = StrBody & "<BR> <BR>"

'HERE'S WHERE DLLBODY IS INSERTED!

    StrBody = StrBody & "<span style='font-size:10.0pt;font-family:Arial;color:green'>" & DLLBody & "</span>"
    StrBody = StrBody & "<BR> <BR> <BR>"
    StrBody = StrBody & "<span style='font-size:10.0pt;font-family:Arial;color:black'>" & "Please open the workbook at the following location:" & "</span>"
    StrBody = StrBody & " <BR><BR>"
    StrBody = StrBody & " <span style='font-size:10.0pt;font-family:Arial;color:black'><a href='file:///\\aragorn\teams\Development\Releases\Documentation\DLL Versions\Get Latest.xlsm'>" & _
        "\\aragorn\teams\Development\Releases\Documentation\DLL Versions\Get Latest.xlsm</a>"
    StrBody = StrBody & " <BR><BR>"
    StrBody = StrBody & "<span style='font-size:10.0pt;font-family:Arial;color:black'>" & "and navigate to the Version3 DB tab." & "</span>"
    StrBody = StrBody & " <BR><BR><BR><BR>"
    StrBody = StrBody & "<span style='font-size:10.0pt;font-family:Arial;color:black'>" & "____________________________________" & "</span>"
    StrBody = StrBody & "<BR>"
    StrBody = StrBody & "<span style='font-size:14.0pt;font-family:Arial;color:green'>" & "Build & Release Team" & "</span> </HTML>"


The idea is that the string variable DLLBody will be generated in a For-Next loop and will contain a number of lines which will be inserted into the middle of the HTML email code. Each line is separated by two line breaks (to put a blank line between each entry).

If, after the For-Next loop I display the contents of DLLBody with MsgBox, the results are fine, but when DLLBody is carried through into the main body of the email, the line breaks are lost and the lines come through as one continuous string.

Probably dead obvious to anyone who knows HTML, but with less than a week's experience, I sadly don't fall into that category.

As usual, all assistance gratefully received.

Pete
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Please ignore this thread - not only was I not able to format it correctly, I also now have the answer = <BR> instead of vbNewLine.
How could I have deleted this thread, once I realised that i didn't need it any longer?
 
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,874
Members
449,056
Latest member
ruhulaminappu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top