I use the following code to send automatic emails, passing a parameter in them :
Const schema = "http://schemas.microsoft.com/cdo/configuration/"
Const cdoBasic = 2
Const cdoSendUsingPort = 2
Dim oMsg, oConf
Dim sDateTimeStamp
Set args = WScript.Arguments
arg1 = args.Item(0)
' E-mail properties
Set oMsg = CreateObject("CDO.Message")
oMsg.From = "[email protected]" ' or "Sender Name <[email protected]>"
oMsg.To = "[email protected]" ' or "Recipient Name <[email protected]>"
oMsg.Subject = "Subject"
oMsg.TextBody = "Transfer of files failed - Check RUNLOG for error. Julian date : " & arg1
' GMail SMTP server configuration and authentication info
Set oConf = oMsg.Configuration
oConf.Fields(schema & "smtpserver") = "smtp server" 'server address
oConf.Fields(schema & "smtpserverport") = 25 'port number
oConf.Fields(schema & "sendusing") = cdoSendUsingPort
oConf.Fields(schema & "smtpauthenticate") = cdoBasic 'authentication type
oConf.Fields(schema & "smtpusessl") = False 'use SSL encryption
oConf.Fields(schema & "sendusername") = "[email protected]" 'sender username
oConf.Fields(schema & "sendpassword") = "password" 'sender password
oConf.Fields.Update()
I would like to add a multiline string in the text message body, i have tried using the _ concat operator like so :
multi = "aaaaaa " & _
"FROM NC301B " & _
"WHERE EDIPROC like 'P30_' " & _
"AND (LF301M > 0) "
but it does not work. Can someone give me pointers? Thank you.
I would like the end body of the email to contain this:
"Transfer of files failed - Check RUNLOG for error."
"Julian date : " & arg1
"Line of text"
"Line of text"
If this is also doable without multi-lining with & _
then i m curious about that also. Thank you!
.TextBody
just place a hardcoded newlinevbNewLine
. – user692942