Just getting starting and have a basic question - how can I pass a variable to a vbscript? In this case, I'm reading a file into a variable and then want to send the contents using Lotus notes. This syntax gives me an invalid character error in the Vbscript where I reference %msg%. If I put %msg% in quotes ("%msg%" ) I just get the string %msg% in the email.
ReadFile>c:\temp\tmp.txt,msg
Message>%msg%
VBSTART
Sub SendNotesMail
Set nSession = CreateObject("Notes.NotesSession")
'Gets the current user's maildatabase
Set db = nSession.GETDATABASE("","")
Call db.OPENMAIL
Set doc = db.CREATEDOCUMENT
Call doc.REPLACEITEMVALUE("SendTo", "[email protected]")
Call doc.REPLACEITEMVALUE("Subject", "Mail sent from VBscript using Lotus Notes")
Call doc.REPLACEITEMVALUE("Body", %msg%)
Call doc.SEND(False)
End Sub
VBEND
VBRun>SendNotesMail
Passing variable to vbscripts
Moderators: JRL, Dorian (MJT support)
I prefer to put my VBS code at the top of the script. Pass the variable into the subroutine by setting it as a subroutine parameter and pass it on the VBRun line.
VBSTART
Sub SendNotesMail(msg)
Set nSession = CreateObject("Notes.NotesSession")
'Gets the current user's maildatabase
Set db = nSession.GETDATABASE("","")
Call db.OPENMAIL
Set doc = db.CREATEDOCUMENT
Call doc.REPLACEITEMVALUE("SendTo", "[email protected]")
Call doc.REPLACEITEMVALUE("Subject", "Mail sent from VBscript using Lotus Notes")
Call doc.REPLACEITEMVALUE("Body", msg)
Call doc.SEND(False)
End Sub
VBEND
ReadFile>c:\temp\tmp.txt,msg
Message>%msg%
VBRun>SendNotesMail,msg
VBSTART
Sub SendNotesMail(msg)
Set nSession = CreateObject("Notes.NotesSession")
'Gets the current user's maildatabase
Set db = nSession.GETDATABASE("","")
Call db.OPENMAIL
Set doc = db.CREATEDOCUMENT
Call doc.REPLACEITEMVALUE("SendTo", "[email protected]")
Call doc.REPLACEITEMVALUE("Subject", "Mail sent from VBscript using Lotus Notes")
Call doc.REPLACEITEMVALUE("Body", msg)
Call doc.SEND(False)
End Sub
VBEND
ReadFile>c:\temp\tmp.txt,msg
Message>%msg%
VBRun>SendNotesMail,msg
MJT Net Support
[email protected]
[email protected]