user379460
user379460

Reputation: 1

Write text file from batch file with embedded vbCRLF

I am using a batch file to write a vbs email file. I am unable to create the text body of the email which includes the vbCRLF code. When the TextBody is written to the Target file, it has executed the first vbCRLF, and the DOS returns errors as it tries to execute the second vbCRLF and the last string. Enclosing it in doucble quotes doesn't work.

echo.TextBody = "Hello,blah blah blah" & vbCrLf & vbCrLf & "worldblah blah", 0, "Message">>Target.txt

The vbCRLF are used to foamt a lengthy text body for the email.

Your help is appreciated.

Upvotes: 0

Views: 900

Answers (1)

Tim Robinson
Tim Robinson

Reputation: 54764

Replace the & with ^&:

echo.TextBody = "Hello,blah blah blah" ^& vbCrLf ^& vbCrLf ^& "worldblah blah", 0, "Message">>Target.txt

It's related to this: Escape angle brackets in a Windows command prompt

Upvotes: 1

Related Questions