A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
Hi,@Rohit Pawar.Welcome to Microsoft Q&A Forum, To address this issue, you might consider using the Exited event of the Process class to handle the event when Outlook is closed. Here is an example of how to modify your code to include event handling for the Exited event:
Process[] processlist = Process.GetProcessesByName(processName);
if (processlist.Length > 0)
{
MessageBox.Show("Outlook Opened");
foreach (Process process in processlist)
{
process.EnableRaisingEvents = true;
process.Exited += OutlookExited;
}
}
private static void OutlookExited(object sender, EventArgs e)
{
MessageBox.Show("Outlook Closed");
}
If you still have questions, please feel free to let me know. The problem will be better solved if more details are described (steps, error messages, and code to reproduce the problem).
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.