Computers & ProgrammingComputers & NetworkingVBScript

Sending an Email Message Using VBScript

There may be instances where you need to automatically send a message from some type of 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 extension 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

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top