I'm trying to send email when user logout or shutdown. There any way to call a function when user logout or shuttdown the computer on c#, i tried to detect when the user logout, but apparently the program is closed before the email is sent.