Link to home
Start Free TrialLog in
Avatar of Rupert Eghardt
Rupert EghardtFlag for South Africa

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("WScript.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.
Avatar of Easwaran Paramasivam
Easwaran Paramasivam
Flag of India image

Instead of Run use Exec and Instead of Quit use Terminate. Please do refer

http://stackoverflow.com/questions/15355332/close-an-application-using-vbscript
"Press any key to continue" sounds more like a pause statement within a .BAT program that may be executing this vbscript.
Avatar of Bill Prew
Bill Prew

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
Avatar of Rupert Eghardt

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("wscript.shell")
to:
set ff = CreateObject("WScript.Shell").Exec("telnet")
* 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.
Yes thanks,
I use TELNET & have onsite SMTP server.
ASKER CERTIFIED SOLUTION
Avatar of dsacker
dsacker
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing")  = 2
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.