I have tried looking for the answer to this question... Forgive me if I have overlooked it.
What I am trying to do is automate sending an email. I have everything I want in this code but the code assumes that Outlook is NOT open.
Is there a way for me to test if Outlook is open before it opens another instance of Outlook?
Microsoft.Win32.RegistryKey key =
Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\\microsoft\\windows\\currentversion\\app paths\\OUTLOOK.EXE");
string path = (string)key.GetValue("Path");
if (path != null)
System.Diagnostics.Process.Start("OUTLOOK.EXE");
else
MessageBox.Show("There is no Outlook in this computer!", "SystemError", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
Since I like clean one-liners, here's what I used:
if (System.Diagnostics.Process.GetProcessesByName("OUTLOOK").Any())
return true;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With