Wednesday, June 27, 2012

Send Email from Windows using VBS and optional SSL Authentication

As I have posted before you can configure Windows Servers to send alerts when they detect errors (commonly logged in the Event Log). If your internal SMTP enforces authentication (I hope using SSL) then the scripts will need to be changed a little bit just to add support for it.

Rather than modifying previous posted scripts I am sharing this time a script that will just send an email from VBS. Optionally you can use authentication if you just supply the credentials: A couple of examples showing how to use it to send internal (sampleDomain) non SSL authenticated emails and externals SSL autheticated ones (gmail)
C:\>cscript c:\scripts\events\sendEmail.vbs 25 "testing smtp from windows vbs" "Just a test"
C:\>cscript c:\scripts\events\sendEmail.vbs 465 "testing smtp from windows vbs" "Just a test" gmaiUserPassword


Mike Martin said...

Hey Nestor, I tried out your VBS sendmail script. You should comment out line 78, because it causes a compile time error.

this is what I got:
C:\Bin\sendmail.vbs(78, 1) Microsoft VBScript compilation error: Expected statement

Nestor Urquiza said...

Biff, Thanks for the heads up. I have moved the code to a gist which does not end up in error formatting.