vbNewLine not working?

G

Guest

I have a userform, and the idea being that people can fill it in with
information and hit the send button, which whisks it away.

I want the information split into lines so its easier to read, rather than
it being a long string.

..HTMLBody = TextBox1.Value & vbCr & TextBox2.Value & vbCrLf & TextBox3.Value
& vbNewLine & TextBox4.Value

trying different types of new line to try and get one of them to work. But I
still end up with all the information in 1 line, all next to each other.....

Full macro:

Private Sub CommandButton1_Click()
Dim iMsg As Object
Dim iConf As Object
Dim sh As Worksheet
Dim rng As Range
Dim Flds As Variant
Dim nam As Variant

nam = Environ("UserName")

Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")

iConf.Load -1 ' CDO Source Defaults
Set Flds = iConf.Fields
With Flds

..Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

..Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "XXX"

..Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

..Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 0
.Update
End With


Application.ScreenUpdating = False
With iMsg
Set .Configuration = iConf
.To = "(e-mail address removed)"
.CC = ""
.BCC = ""
.From = """Pre Visit Call Missed"" <no@ddress>"
.Subject = "Completed by " & nam
.HTMLBody = TextBox1.Value & vbCr & TextBox2.Value & vbCrLf &
TextBox3.Value & vbNewLine & TextBox4.Value & vbCrLf & TextBox5.Value &
vbCrLf & TextBox6.Value & vbCrLf & TextBox7.Value
.Send
End With

Set iMsg = Nothing
Set iConf = Nothing

Unload Me
End Sub
 
G

Guest

Sorry. It works for me in InputBoxes so I was hoping it work in your
situation. Maybe somebody else will have the right answer.
 
G

Guest

I found this bit of code and hoped something in it might be of use.

Const NewFileName = "NewFile.txt"
Const SourceFileName = "source.txt"

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(SourceFileName)
strLines = Split(objFile.ReadAll,vbcrlf)
objFile.Close
Set NewFile = objFSO.CreateTextFile(NewFileName, True)
For Each strLine in strLines
if strLine<>"" Then
Arr = Split(strLine,",")
NewLine = ""
for x = 0 To 3
NewLine = NewLine & Arr(x) & ","
next
NewLine = replace(NewLine,Chr(34),"")
NewLine = "dn: " & Left(NewLine,Len(NewLine)-1) & vbNewLine
NewLine = NewLine & "changetype: modify" & vbNewLine
NewLine = NewLine & "replace: employeeID" & vbNewLine
NewLine = NewLine & "employeeID: " & Arr(4) & vbNewLine
NewLine = NewLine & "-" & vbNewLine
NewFile.WriteLine NewLine
end if
Next
NewFile.Close
 
T

Tim

Use "<br>" if you're composing HTML.
HTML tends to ignore whitespace other than a single space character.

Or wrap all content in <pre></pre>

Tim
 
G

Guest

D'oh, didn't think to try HTML, cheers.

Tim said:
Use "<br>" if you're composing HTML.
HTML tends to ignore whitespace other than a single space character.

Or wrap all content in <pre></pre>

Tim
 
G

Guest

I'm in the boat with you. I have used "<br>" plenty of times but my
"one-tracked mind" couldn't get the track switchto work.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top