Rupert Eghardt
asked on
Quit VB Script
Hi Guys,
I have a small VB script that I'd like to use for sending out a test mail;
I'd like the script to close automatically when done sending,
At the moment it gives "Press any key to continue" at the end of the script and does not close the session window.
The script is as follows;
Option explicit
Dim oShell
set oShell= Wscript.CreateObject("WScr ipt.Shell" )
oShell.Run "telnet"
WScript.Sleep 1000
oShell.Sendkeys "open mail.server.co.za 25~"
WScript.Sleep 1000
oShell.Sendkeys "helo server.co.za~"
WScript.Sleep 1000
oShell.Sendkeys "mail from: sender@server.co.za~"
WScript.Sleep 1000
oShell.Sendkeys "rcpt to: recipient@server.co.za~"
WScript.Sleep 1000
oShell.Sendkeys "data~"
WScript.Sleep 1000
oShell.Sendkeys "Subject:Test Procedure Confirmation~"
WScript.Sleep 1000
oShell.Sendkeys "~"
WScript.Sleep 1000
oShell.Sendkeys "~"
WScript.Sleep 1000
oShell.Sendkeys "This is a confirmation of the Test procedure~"
WScript.Sleep 1000
oShell.Sendkeys ".~"
WScript.Sleep 1000
oShell.Sendkeys "quit~"
WScript.Sleep 1000
Wscript.Quit
* I've tried adding another QUIT to the end of the script, but doesn't help.
I have a small VB script that I'd like to use for sending out a test mail;
I'd like the script to close automatically when done sending,
At the moment it gives "Press any key to continue" at the end of the script and does not close the session window.
The script is as follows;
Option explicit
Dim oShell
set oShell= Wscript.CreateObject("WScr
oShell.Run "telnet"
WScript.Sleep 1000
oShell.Sendkeys "open mail.server.co.za 25~"
WScript.Sleep 1000
oShell.Sendkeys "helo server.co.za~"
WScript.Sleep 1000
oShell.Sendkeys "mail from: sender@server.co.za~"
WScript.Sleep 1000
oShell.Sendkeys "rcpt to: recipient@server.co.za~"
WScript.Sleep 1000
oShell.Sendkeys "data~"
WScript.Sleep 1000
oShell.Sendkeys "Subject:Test Procedure Confirmation~"
WScript.Sleep 1000
oShell.Sendkeys "~"
WScript.Sleep 1000
oShell.Sendkeys "~"
WScript.Sleep 1000
oShell.Sendkeys "This is a confirmation of the Test procedure~"
WScript.Sleep 1000
oShell.Sendkeys ".~"
WScript.Sleep 1000
oShell.Sendkeys "quit~"
WScript.Sleep 1000
Wscript.Quit
* I've tried adding another QUIT to the end of the script, but doesn't help.
"Press any key to continue" sounds more like a pause statement within a .BAT program that may be executing this vbscript.
How are you executing the script, this sounds like a proble there, maybe a PAUSE in a BAT file or such. Rather than the vbs script.
~bp
~bp
ASKER
Thanks for the help;
I am opening a DOS window and run vbscript.vbs from DOS
The script opens Telnet and completes the command lines successfully (e-mail sent)
The last lines in the script say:
221 2.2.1 Service closing transmission channel (#3.08)
Connection to host lost.
Press any key to continue ...
I am not running any batch file at this time.
The script exactly as above - executed from DOS prompt
I tried changing
set oshell = wscript.createObject("wscr ipt.shell" )
to:
set ff = CreateObject("WScript.Shel l").Exec(" telnet")
* and use terminate instead,
However, then I get "ff" variable undefined
I am still VB script novice - will appreciate any help :-)
I am opening a DOS window and run vbscript.vbs from DOS
The script opens Telnet and completes the command lines successfully (e-mail sent)
The last lines in the script say:
221 2.2.1 Service closing transmission channel (#3.08)
Connection to host lost.
Press any key to continue ...
I am not running any batch file at this time.
The script exactly as above - executed from DOS prompt
I tried changing
set oshell = wscript.createObject("wscr
to:
set ff = CreateObject("WScript.Shel
* and use terminate instead,
However, then I get "ff" variable undefined
I am still VB script novice - will appreciate any help :-)
You're using telnet to email? If so, do you have SMTP?
If yes to these, I currently do SMTP emailing via vbscript that I can share.
If yes to these, I currently do SMTP emailing via vbscript that I can share.
ASKER
Yes thanks,
I use TELNET & have onsite SMTP server.
I use TELNET & have onsite SMTP server.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks!!
Does this script require internet access?
The machine where the script runs has access to a local SMTP server, but don't have internet access ...
I am concerned about these "http://" lines?
objMail.Configuration.Fiel ds.Item("http://schemas.microsoft.com/cdo/configuration/sendusing" ) = 2
Does this script require internet access?
The machine where the script runs has access to a local SMTP server, but don't have internet access ...
I am concerned about these "http://" lines?
objMail.Configuration.Fiel
It shouldn't be necessary for internet access. You'll have to play with it. Those are for configuration where possible.
You can try it with and without them.
You can try it with and without them.
http://stackoverflow.com/questions/15355332/close-an-application-using-vbscript