Click here to Skip to main content
15,897,273 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
Hi
I have a window service created in c#. This service sends mail automatically.

But my prob is that if a wrong emailID get then an exception occurs and service stops.
I also set the property of service on first failure , 2nd failure , and so on .
I also write code for restarting service using service control. But my service still not restarting.

Please help me to get out of this problem.
Thanks in advance .
Any help will be appreciated.

Sandeep beniwal
9468479258
Posted
Comments
Sergey Alexandrovich Kryukov 23-Aug-13 0:53am    
There can be too many ways to screw up things. How can we know how you did it?
—SA

1 solution

we are always use two common event:

OnStart
OnStop

You can write on OnStart

if your SmtpMail.Send(message) method returns no error, it means the email was sent to the SMTP server, then you are out of your jurisdiction, that is how far you can know. Not use exception in that and it make service stop.

Then you can do anything what you need.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900