Send an Email Message Using VBScript

Friday, October 28, 2011

There may be instances where you need to automatically send a message from some type application or program. Or, you may want to send yourself an alert when a service suddenly stops on one of your critical Windows 2003 Server. Without some type of monitoring application or agent running on the system, you'll need some type of custom program or script to send out a message with pertinent information.

Here is an example of a script that uses CDO to send an email message from a computer using a remote SMTP server. Replace "" with the hostname of the SMTP server that you will be sending mail through. You can modify the other properties such as who the mail is from and who the mail is being sent to. Just copy and paste into a text editor such as Notepad, then save with the extention of .vbs.

Set objEmail = CreateObject("CDO.Message")
objEmail.From = "[email protected]"
objEmail.To = "[email protected]"
objEmail.Subject = "Service Is Down"
objEmail.Textbody = "The Service ### has stopped."
objEmail.Configuration.Fields.Item _
("") = 2
objEmail.Configuration.Fields.Item _
("") = _
objEmail.Configuration.Fields.Item _
("") = 25

Did you find the page informational and useful? Share it using one of your favorite social sites.

Recommended Books & Training Resources

Advanced VBScript for Microsoft Windows Administrators Microsoft WSH and VBScript Programming for the Absolute Beginner