I have the following code in visual basic , which I am running through visual studio .
Module Module1
Sub Main()
On Error GoTo errorHandler
Dim oLapp As Object
Dim oItem As Object
oLapp = CreateObject("Outlook.application")
oItem = oLapp.createitem(0)
'
With oItem
.Subject = "A MAIL"
.To = "[email protected]"
.body = "2018 RUSSIA IS OURS"
.Send
End With
Console.Write("KROOOOOOOOSSSSSS")
Console.Read()
'Set oLapp = Nothing
'Set oItem = Nothing
errorhandler:
Console.Write("jkjk")
End Sub
End Module
This code is purported to send an email through outlook . However , I thought of doing this through command prompt and I got to know about "cscript" command which is used to run VB scripts in windows command prompt .
So , I put the following code in an notepad file and saved it with .vbs extension . Then when I tried calling this file using cscript , I got an error . It said syntax error at line 7 , col23 .
That line turns out to be :
On Error goto Errhandler
As such I commented that line out and tried running again and got an error again in line 8 , stating "expected end of statement .
So , I thought cscript might still be supporting "set" and "let" and hence put set in line 8 and I got the same error again .
So , is there any difference in the compilation of visual basic code in both these places . What will be the equivalent code of the code presented here that can be run via cscript and perform the task of sending an email through outlook .