Outlook VSTO integration - Outlook shutdown event for sync

I'm working on a VSTO Outlook 2007 add-in that basically syncs Outlook data with a web service. There are three types of sync that I want to have in the app: startup sync, manual sync, and shutdown sync. The first two are simple and have already been done.

However, I am having trouble finding the appropriate event to trigger my sync on shutdown. I tried to connect to the following two events, but it seems like they are fired too late when the add-in doesn't have access to Outlook data and it just doesn't work:

  • ((Outlook.ApplicationEvents_Event)Application).Quit

    (It starts first, but it's too late to access and update Outlook Data Collections).
  • ThisAddIn.Shutdown

    (it fires after Quit

    , so that's not good either)

Are there any other events that were fired prior to the ones that were disabled in Outlook that I could use? Or maybe someone knows some other way to handle sync when the Outlook add-in is shutting down?

+2


source to share


1 answer


Explorer.Close () and Inspector.Close () fire before Application.Quit () - in them you can check:

  • In Explorer.Close (): Application.Explorers.Count <= 1 and Application.Inspectors.Count == 0
  • In Inspector.Close (): Application.Explorers.Count == 0 and Application.Inspectors.Count <= 1


If so, Outlook will close and you can start your events. Just keep in mind that Outlook can be launched without windows (automation, etc.) if that's a problem for you.

+3


source







All Articles