currently I'm developing a small VSTO Outlook Add-In. While I've some experience in C#, I'm not very familiar with the Outlook object model.
The scope of my Add-In is pretty easy. My colleagues and I have a shared Outlook inbox (beside our own ones). The shared inbox has categories and subfolders with the same name. E.g. there’s a subfolder “Michael” and there exists a category “Michael”. When somebody applies his own category to a mail in the shared inbox, the mail is automatically moved to the matching subfolder, the reply window opens and the sender address is changed from the shared email address to the personal one (our IT adjusted the shared mail address to not be able to send emails).
Right now the current version of the Add-In works flawlessly, beside the fact that it somehow stops to work after some time. So when I start outlook, everything works like expected, I can categorize mails in the shared inbox and they’re moved etc. But after some time (sometimes hours, sometimes even after 30 minutes) it’s not working anymore. Neither the debug view in Visual Studio nor Outlook are indicating any errors. At first I thought something terminated my Add-In, but then I configured a timer to send a “I’m alive” message to the log file and now I can see that the Add-In is still running.
Hence I assume that somehow the events I’ve registered to are not sufficient to keep track of the users action in Outlook. This can be confirmed as a break point in the event handlers is not triggered when this behavior appears and a mail is categorized. I’ve registered to the following events in the startup method:
Outlook.Application application = this.Application;
Outlook.Inspectors inspectors = application.Inspectors;
Outlook.Explorer activeExplorer = this.Application.ActiveExplorer();
// When a new mail is created, trigger Inspectors_AddTextToNewMail() methode
inspectors.NewInspector = new Outlook.InspectorsEvents_NewInspectorEventHandler(Inspectors_AddTextToNewMail);
// Whenever something in the explorer is selected, run the event handler
activeExplorer.SelectionChange += ActiveExplorer_SelectionChange;
In the selectionChange() Event-Handler another Event-listener for the change of the mail properties is registered:
Outlook.MailItem mailItem = selectedItem as Outlook.MailItem;
// Register an Event handler that listens for changes of the mailitem's properties in order to check the category
mailItem.PropertyChange += MailItem_PropertyChange;
This way I can check whether a category has been applied.
But after some time not even the ActiveExplorer_SelectionChange Event is triggered, independent on what I select in Outlook.
Does anybody know whether I missed something? Do I have to register to further events so the Add-In won’t lose track?
Thanks for your help in advance!
Best Regards,
Percy