Click here to Skip to main content
15,886,724 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want create a application which sends a mail when that system on which app is running is going to shutdown.

Or application which close itself at the last when machine is going to shutdown.

Thanks

What I have tried:

I want create a application which sends a mail when that system on which app is running is going to shutdown.

I have written code which send mail successfully just want idea on above stated scenario.

Thanks
Posted
Updated 17-Feb-16 0:15am
v2
Comments
Patrice T 17-Feb-16 6:18am    
start working

1 solution

 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 17-Feb-16 11:47am    
That's exactly the way, a 5.
Let's hope that the inquirer will figure out to use SystemEvents class and all mail message stuff, such as MailMessage...
—SA
Mangesh9692 25-Feb-16 5:42am    
Hi implement some code that i posting here which shutdown the machine but does not send email.

private static void SystemEvents_SessionEnding(object sender, SessionEndingEventArgs e)
{
Logger.Log("System is going to shutdown" + e.Reason, 3);
Services.SendAlert("Attention! System is going to shutdown","The configured services are going to stop due to system shutdown or by reason"+e.Reason);
e.Cancel = false;
}

Is there is any way to delay the system shutdown and send mail successfully.
when i running appliation in debug mode it successfully send message.

Thanks
Suvabrata Roy 25-Feb-16 7:25am    
You can put sleep to wait but first be sure delay is the cause of your malfunction.

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



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