Simple email VB Script


I have an email script I was using at previous company.  Now I want to incorporate something similiar at different company.  However I can't get it to work.  So instead of duplicating it, I was wondering if there is some very, very, very basic email script that I can use to validate whether or not I have the 'email server' correctly.  Idea would be to successfully email myself by executing it.  Then I can modify the more complex one that passes in variables etc.  The erors on VB are cryptic to me and can't tell what the issue is.

Here's my current code:

'%ENV_NAME% Variable passed into the script
strLocation1 = Wscript.Arguments.Item(0)

'%EMAILSVR% Variable passed into the script
strLocation2 = Wscript.Arguments.Item(1)

'%EMAIL_TO% Variable passed into the script
strLocation3 = Wscript.Arguments.Item(2)

'%LOGDIR% Variable passed into the script
'strLocation4 = Wscript.Arguments.Item(3)

'%LOGFILENAME% Variable passed into the script
'strLocation5 = Wscript.Arguments.Item(4)

strTo = "" & strLocation3 & ""
Set objfso = CreateObject("Scripting.FileSystemObject")

strSubject = "WARNING!! - Another Hyperion maintenance is processing on " & strLocation1 & ""
strBody = "Unable to execute Hyperion maintenance process on " & strLocation1 & ".  There is another process currently running.  Please try again later or when the other process is finished." 
'strAttachFile = strLocation4 & "" & strLocation5 & ""

EMail "", strTo, strSubject, strBody,"" & strLocation2 & "" ,strAttachFile

Sub EMail(sourceAddr,destAddr,subjectText,textBody,SMTPserver)
         Set objEmail = CreateObject("CDO.Message")
         With objEmail
                 .From = sourceAddr
                 .To = destAddr
                 .Subject = subjectText
                 .TextBody = textBody
				 '.AddAttachment strAttachFile
                 .Configuration.Fields.Item ("") = 2
                 .Configuration.Fields.Item ("") = "" &strLocation2 & ""
                 .Configuration.Fields.Item ("") = 25
         End With
End Sub

Open in new window

Thanks for all help.  Always tricky when trying to get email working for some reason.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NVITEnd-user supportCommented:
Looks like you're calling the strAttachFile but it's missing from the Sub

Also, you have:
&strLocation2 &

Open in new window

Also, your Sub has SMTPserver but isn't using it.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Steve KnightIT ConsultancyCommented:
I have a couple here if wanted of mine, search "email" on the page.

You can also just send it manually using telnet.  For Windows 7+ you normally have to go into add an extra feature "Telnet client" in the control panel but aside from that just type (and no backspacing):

telnet x.x.x.x 25

(now the mail server will respond with it's banner.  if it just hangs try pressing Return.  If that is no good it will probably time out and maybe not responding or firewalled so you can't connect.

Now type these following each line by return, you can't correct any mistakes.  If you make one press return and type another line or start again!


helo mypc
mail from:
rcpt to:
rcpt to:
From: Appears on the from line
To: Appears on the to line
Subject: Subject line

Open in new window

Now enter a blank to start the message and end it with a single .

Now this is the message body.

Open in new window

Sounds quite complicated but do it a few times and you can soon check an SMTP server without the need for any scripts or programs.

elwayisgodAuthor Commented:
That was it.  It's working now.  Thanks for help, greatly appreciated.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.