Search code examples
c#outlookoutlook-addin

How To Determine If Outlook Is Fully Launched from my C# Add-In?


Windows users can right-click on any file in explorer and go to Send to > Mail recipient

This launches a new message in a compose inspector with the file attached and some pre-populated text. However, it does not seem to fully launch the Outlook application.

This causes problems when my Add-In tries to close the inspector and run some cleanup code (which it does successfully when Outlook is fully launched). The Add-In suspends and crashes Outlook when trying to run the clean up code because closing the inspector is trying to close Outlook.

Is there a way using C# to determine whether Outlook is fully launched or just in this compose-only mode?


Solution

  • What is the problematic snippet of your code?

    You can check if there are any open explorers by checking the Application.Explorers.Count property.