MailItem Unload event fires non-deterministically with custom form-region

  • Thread starter mail.daniel.grigg
  • Start date
M

mail.daniel.grigg

Hi all,

I've written an add-in that creates a custom form-region for reading/preview mailitems. In short, I've wired the Application.ItemLoad and MailItem.Unload events under the expectation those events will fire successively for aMailItem with my message class. That is,

* User selects mail-item A in inbox
* ItemLoad for A fires
* User selects a different mail-item B
* Unload for A fires
* ItemLoad for B fires
* User selects A again
* Unload for B fires
* ItemLoad for A fires

This is the default behaviour of outlook mail-items (IPM.Note message class).

However, with my custom form-region, I receive the ItemLoad event as expected, but Item.Unload doesn't fire in step 4. Indeed, it seems to fire some arbitrary time in the future. Worse, performing the above can result ItemLoad being fired twice (meaning any mail-items events that are wired up are added twice, requiring hacks like removing then adding the handlers).

I created a new test project that simply wires up many of the Application and MailItem events and logs them to narrow the scope of the add-in, but even that project has the same behaviour.

My environment is Windows 7 64-bit, running Visual Studio 2012 and Outlook 2007 32-bit (had to tweak the project file to launch outlook 2007 but that shouldn't effect anything).

I believe I'm either missing something blindingly simple, hence the lack ofpeople reporting similar issues, or I've encountered some nasty bug in VSTO.

I'd really appreciate any insights people have.

Cheers,
Daniel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top