How can I pass a parameter from batch to vbscript? My batch script sends out an email at the end of the automated execution. For that it uses/calls my vbscript (email.vbs) t
Alright, I am updating that question I had. It's finally working, with all of your help, guys. Thanks. Here is how I called the vbscript and passed a parameter to it:
cscript //nologo fail_mail.vbs something.sql 'something.sql is the param. that i'm passing.
Here is what my vbscript for mail looks like:
Const ForReading = 1
Set args = WScript.Arguments
arg1 = args.Item(0) 'the parameter from batch comes in here to arg1
...
...
ToAddress = "my@address.com"
MessageSubject = "WORKED"
MessageBody = "Success"
MessageAttachment = ""&arg1&"" 'here those quotes are important. dk why.
Set ol = WScript.CreateObject("Outlook.Application")
Set ns = ol.getNamespace("MAPI")
Set newMail = ol.CreateItem(olMailItem)
newMail.Subject = MessageSubject
newMail.Body = MessageBody & vbCrLf & MyTime
newMail.RecipIents.Add(ToAddress)
newMail.Attachments.Add(MessageAttachment)
newMail.Send
And it is working. *One can pass more than one parameters using the same technique.