How do I make a service stopping trigger an e-mail?

I am trying to set up an auto email when a specific service stops.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Got to the service and look at the properties. on the recovery tab on failure set to run a program. Then create a vbs script using the following code (changing the bits in bold) and then run that on failure:

Set objEmail = CreateObject("CDO.Message")

objEmail.From = ""
objEmail.To = ""
objEmail.Subject = "Server down"
objEmail.Textbody = "Server1 is no longer accessible over the network."
objEmail.Configuration.Fields.Item _
    ("") = 2
objEmail.Configuration.Fields.Item _
    ("") = _
objEmail.Configuration.Fields.Item _
    ("") = 25

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
seanwebAuthor Commented:
That's great thanks, how can I test it though? As stopping the service manually I would guess is not picked up as a failure, right?
seanwebAuthor Commented:
Also, I assume that writing this out on notepad and saving as a .vbs file is adequate, yes?
SolarWinds® VoIP and Network Quality Manager(VNQM)

WAN and VoIP monitoring tools that can help with troubleshooting via an intuitive web interface. Review quality of service data, including jitter, latency, packet loss, and MOS. Troubleshoot call performance and correlate call issues with WAN performance for Cisco and Avaya calls

yes thats right just save as .vbs

a bit tricky to test I agree. You can obviously test the script on it's own.
seanwebAuthor Commented:
Thanks, I have tested the script and have an error on line 15, anything you can see?
what smartshost did you enter in the script. For example - I use a ISP called plusnet so my smarthost is but rememebr this must be the smarthost of the line you are going out off.

seanwebAuthor Commented:
AhHa! Missed that, working perfectly now, thank you very much.
seanwebAuthor Commented:
Great script, very useful, took no time at all.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Network Management

From novice to tech pro — start learning today.