elwayisgod
asked on
Simple email VB Script
Hi,
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:
Thanks for all help. Always tricky when trying to get email working for some reason.
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 "Admin@Company.com", 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 ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "" &strLocation2 & ""
.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Configuration.Fields.Update
.Send
End With
End Sub
Thanks for all help. Always tricky when trying to get email working for some reason.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That was it. It's working now. Thanks for help, greatly appreciated.
http://scripts.dragon-it.co.uk/links/batch-monitor-ping-email
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!
Steve
Open in new window
Now enter a blank to start the message and end it with a single .
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.
Steve