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?
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.
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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.