What is the correct event?

Add-in Express™ Support Service
That's what is more important than anything else

What is the correct event?
 
Jugal Shah




Posts: 8
Joined: 2015-07-30
Hello all,

So I've built an add-in that uses adxOutlookAppEvents1_ExplorerSelectionChange to parse a message when a user clicks on it. I then save the result of the parse in a custom user property as it makes no sense to parse the same message with the same logic over and over. It then populates a combobox on the toolbar of the add-in with the things parsed from the message. The 2nd time a user clicks on a message, it will see the user property created earlier and use that rather than re-parse.

Where I'm having an issue, though, is if a user actually double clicks and opens an email instead of just viewing it in the preview pane. In this case, when the user goes to close that email, it pops up a box saying "The properties of the message "XYZ" have been changed. Do you want to save changes to this message?" The options are Yes, No and Cancel.

In further testing, it seems that user properties are not written until the user actually clicks away to the NEXT message. So what I think is happening is that when the user double clicks a message, the first click causes selection change event to fire the associated handler (the parsing code). The message then opens with the 2nd click. However, now when the email is closed, it detects that there are pending changes and opens the box. I'm just not sure how to fix it. The easiest fix is finding a similar but different event to handle, perhaps one in between when the message is fully loaded and displayed to the user - unfortunately, I don't see such an event.

Would appreciate any help/insight into this. It's not a critical bug, but it is a showstopper to mass rollout - people will be understandably upset if they get an annoying popup every time they close an email!
Posted 13 Aug, 2015 09:56:07 Top
Andrei Smolin


Add-in Express team


Posts: 17125
Joined: 2006-05-11
Hello Jugal,

You need to save the message after you set the user property. I think you need to do the same in case of ExplorerSelectionChange.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 13 Aug, 2015 10:31:30 Top
Jugal Shah




Posts: 8
Joined: 2015-07-30
Aha! So simple!! I guess it implicitly saves when you click on another message, which wasn't happening when you open it. Thank you Andrei :)
Posted 13 Aug, 2015 12:37:50 Top
Andrei Smolin


Add-in Express team


Posts: 17125
Joined: 2006-05-11
Hello Jugal,

Jugal Shah writes:
I guess it implicitly saves when you click on another message, which wasn't happening when you open it.


I strongly recommend that you check this. Does the user property persists between sessions? If not, this can be an indication that your code doesn't release COM objects.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 14 Aug, 2015 00:42:02 Top
Jugal Shah




Posts: 8
Joined: 2015-07-30
I strongly recommend that you check this. Does the user property persists between sessions? If not, this can be an indication that your code doesn't release COM objects.


Thanks Andrei. Indeed, I had confirmed it was saving - I added the user-defined field into my view and saw the property persisting after restarting Outlook. I also saw that column populated as soon as I clicked on another message, I just hadn't put 2+2 together that it was probably doing an implicit save. My guess is that the preview view is made to allow work to get done quickly, so it probably assumes certain things (like whether to save a message) instead of popping up questions.

Also, yes, per the developers guide, I've been careful to remember to release COM objects as well. Do you know whether I should release the userproperty object as well as the mail item, or just the item? I'm currently doing both to be on the safe side.
Posted 14 Aug, 2015 08:11:55 Top
Andrei Smolin


Add-in Express team


Posts: 17125
Joined: 2006-05-11
Great. You need to release three objects: the UserProperty object, the UserProperties collection, and the item itself.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 14 Aug, 2015 08:17:17 Top