Set Body Line Break

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
colossus02
Posts: 4
Joined: 11 Feb 2016 16:41

Set Body Line Break

#1 Post by colossus02 » 11 Feb 2016 16:51

Can anybody help me with this code? It works fine, but I was trying to find out how to enter a line break between the two sentences in the body.

Code: Select all

admin::email-bat.cmd:::::::::::::::::::::::::::::::::::::::::::::::::::::
@echo
setlocal

:: defaults
set From=xxxx@domain.com
set To=xxxx@domain.com
set Subj="Backup Complete"
set Body="Some Text Some Text Some Text  %time%. NextLine Some Text Some Text Some Text"
set Serv=smtp.domain.com
set Auth=user
set Pass=pass
set fileattach=

:: if command line arguments are supplied then use them
if "%~7" NEQ "" (
set From=%1
set To=%2
set Subj="%~3"
set Body="%~4"
set Serv=%5
set "Auth=%~6"
set "Pass=%~7"
set "fileattach=%~8"
)

call :createVBS "email-bat.vbs"

call :send %From% %To% %Subj% %Body% %Serv% %Auth% %Pass%
del "%vbsfile%" 2>nul
goto :EOF

:send
cscript.exe /nologo "%vbsfile%" %1 %2 %3 %4 %5 %6 %7 >nul 2>nul
goto :EOF

:createVBS
set "vbsfile=%~1"
del "%vbsfile%" 2>nul
set cdoSchema=http://schemas.microsoft.com/cdo/configuration
echo >>"%vbsfile%" Set objArgs       = WScript.Arguments
echo >>"%vbsfile%" Set objEmail      = CreateObject("CDO.Message")
echo >>"%vbsfile%" objEmail.From     = objArgs(0)
echo >>"%vbsfile%" objEmail.To       = objArgs(1)
echo >>"%vbsfile%" objEmail.Subject  = objArgs(2)
echo >>"%vbsfile%" objEmail.Textbody = objArgs(3)
if defined fileattach echo >>"%vbsfile%" objEmail.AddAttachment "%fileattach%"
echo >>"%vbsfile%" with objEmail.Configuration.Fields
echo >>"%vbsfile%"  .Item ("%cdoSchema%/sendusing")        = 2 ' not local, smtp
echo >>"%vbsfile%"  .Item ("%cdoSchema%/smtpserver")       = objArgs(4)
echo >>"%vbsfile%"  .Item ("%cdoSchema%/smtpserverport")   = 25
echo >>"%vbsfile%"  .Item ("%cdoSchema%/smtpauthenticate") = 1 ' cdobasic
echo >>"%vbsfile%"  .Item ("%cdoSchema%/sendusername")     = objArgs(5)
echo >>"%vbsfile%"  .Item ("%cdoSchema%/sendpassword")     = objArgs(6)
echo >>"%vbsfile%"  .Item ("%cdoSchema%/smtpusessl")       = False
echo >>"%vbsfile%"  .Item ("%cdoSchema%/smtpconnectiontimeout") = 25
echo >>"%vbsfile%"  .Update
echo >>"%vbsfile%" end with
echo >>"%vbsfile%" objEmail.Send
rem

colossus02
Posts: 4
Joined: 11 Feb 2016 16:41

Re: Set Body Line Break

#2 Post by colossus02 » 24 Feb 2016 14:46

Please help??

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: Set Body Line Break

#3 Post by Squashman » 24 Feb 2016 19:13

You are essentially executing a Vbscript. So use that to your advantage.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Set Body Line Break

#4 Post by foxidrive » 25 Feb 2016 17:21

Yes, and google VbCrLf

Post Reply