By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,934 Members | 1,366 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,934 IT Pros & Developers. It's quick & easy.

Service Question - Sending Email on successful startup.

P: n/a
I have a service that will periodically send email messages to system
adminstrators. I would like for this service to send a email notification
whenever the service is started and when it is stopped. I placed attempted
to do that from the OnStart event procedure... but any messages sent during
the OnStart procedure are not sent. But when the service is stopped, the
email messages from both the OnStart and OnStop event procedure are sent.

How can I send email messages from a service when it starts successfully?
Apparently the OnStart event procedure is not the place to do it. I looked
at the ServiceBase class and didn't see any other events or methods that
would apparently do what I need.

Thanks!
Oct 2 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Further testing shows that the email messages sent during the OnStart event
procedure are *eventually* sent - after a delay of 1-2 minutes.

-S

"Smithers" <A@B.comwrote in message
news:ON****************@TK2MSFTNGP03.phx.gbl...
>I have a service that will periodically send email messages to system
adminstrators. I would like for this service to send a email notification
whenever the service is started and when it is stopped. I placed attempted
to do that from the OnStart event procedure... but any messages sent during
the OnStart procedure are not sent. But when the service is stopped, the
email messages from both the OnStart and OnStop event procedure are sent.

How can I send email messages from a service when it starts successfully?
Apparently the OnStart event procedure is not the place to do it. I looked
at the ServiceBase class and didn't see any other events or methods that
would apparently do what I need.

Thanks!

Oct 2 '07 #2

P: n/a
"Smithers" <A@B.comwrote in message
news:ON****************@TK2MSFTNGP03.phx.gbl...
>I have a service that will periodically send email messages to system
adminstrators. I would like for this service to send a email notification
whenever the service is started and when it is stopped. I placed attempted
to do that from the OnStart event procedure... but any messages sent during
the OnStart procedure are not sent. But when the service is stopped, the
email messages from both the OnStart and OnStop event procedure are sent.

How can I send email messages from a service when it starts successfully?
Apparently the OnStart event procedure is not the place to do it. I looked
at the ServiceBase class and didn't see any other events or methods that
would apparently do what I need.

Thanks!

The OnStart method should only be used to perform basic service
initialization stuff, when OnStart doesn't return within 30 seconds after
the SCM posted the Start command, the SCM will flag the service as "failed
to start" and kill the service process. So, sending a mail from within
OnStart makes no sense, at this point, the Service didn't yet start and you
have no guarantee it ever will.

Willy.
Oct 3 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.