ADXOutlookItemEvents.ConnectTo can take up to few seconds

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

ADXOutlookItemEvents.ConnectTo can take up to few seconds
Performance issue when connecting to events in outlook 2007 
Andrei Smolin


Add-in Express team


Posts: 15353
Joined: 2006-05-11
Hello Jakub,

Please send your skeleton add-in and related log records (if any) to the support email address; find it in {Add-in Express installation folder}\readme.txt; please make sure your email contains a link to this topic.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 04 Jan, 2018 09:55:06 Top
Andrei Smolin


Add-in Express team


Posts: 15353
Joined: 2006-05-11
Hello Jakub,

Thank you for sending me the skeleton add-in project. In fact it is rather involved. I suggest simplifying it.

There's at least one pattern in which you don't release COM objects:

if (inspector.CurrentItem == null) {whatever}

You need to save the result of inspector.CurrentItem to a variable, check the variable and release it after use.

This may relate to the issue: every such call creates a COM object; you need to release all of them.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 09 Jan, 2018 11:55:05 Top
Gutek Jakub




Posts: 34
Joined: 2017-06-06
Hi Andrei,

thanks, will add these few releases but imo this is not the issue. I had version without release at all and for people that it worked it still worked and for this few users that had issues still had same issue after same amount of time.

How do you propose to simplified it? just a generic answer like: change how you handle send and replys to.... would be ok. i'm asking completely honestly as i can't see more ways to improve at least this addinmodule.cs class. when i think there is something to simplified then there is a case where this will not work.

I need to react on:
1) Add text (plus select proper button) to mail on new email
2) Read email and add text to email (plus select proper button) on reply and forward in window and inline mode
3) Set text and button on attachment add/remove including: Send To | Mail Recipient from explorer and Send as file from office applications
4) Keep UI in sync with what is selected on multiple outlook mail windows (so buttons are showed properly selected when seeing 2-3 windows at once)

I think i did manage to cut almost half of the code for outlook in recent months and only handle like 5-6 events from outlook plus 5 events per email.

Only (1) is straight forward. 2 and 3 are doing things like:
1) adding/updating text
2) reading email to find existing text
3) reading attachments
4) selecting proper buttons

Kind regards
Posted 09 Jan, 2018 14:45:02 Top
Andrei Smolin


Add-in Express team


Posts: 15353
Joined: 2006-05-11
Hello Jakub,

I wasn't correct saying "symplify". I suggest cutting out blocks of code to locate the issue. Say, you can stop handling inline responses and explorer-related events, cut NLOG out (replace its logger with a custom class with stubs), stop handling PropertyChanging events, and/or turn the timer off.

I've found the following issues in your code. I regard them as minor; the most part of code doesn't show any problems.

1) When handling events of Ribbon controls, don't use the Active* property of the host's Application object (e.g. ExcelApp.ActiveWindow); instead, get the context as described in section Determining a ribbon control's context here.

2) When dealing with inline responses, use the InlineResponseEx and InlineResponseCloseEx events: these provide the Outlook.Explorer object which is the source of the event.

3) In Outlook 2007, ItemContextMenuDisplay (as well as other *ContextMenuDisplay events) let you connect to the object (say, Outlook item) for which the context menu is about to show. You need to use the ContextMenuClose event to disconnect from that object.

Gutek Jakub writes:
I had version without release at all and for people that it worked it still worked and for this few users that had issues still had same issue after same amount of time.


When I describe your issue to our guys, their first reaction is invariably "unreleased COM objects". From our experience, non-released COM objects produce issues that are can be commonly named "strange". Typically, they are difficult to reproduce and/or explain. It's rather shaky, I know, but this is what you have.

Considering other possibilities. Does the user have any problem connecting to their Exchange? Slow synchronization? Did you ever reproduce this issue on a PST? Is it reproducible for you?

A suggestion: let the user repair their Outlook.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 10 Jan, 2018 10:45:01 Top
Gutek Jakub




Posts: 34
Joined: 2017-06-06
Hi Andrei,

Thanks for this. I have updated code to use Ex events and to disconnect from item in *MenuClose. I also did checked all places with Active* on outlook ribbon and I think there were non regarding outlook.

I was giving users few options with app:


  • Same I provided to you
  • Without timer
  • Without inline response


But I did not try without handling property change events. Will try that. However its not easy to test this, as it all depends on willingness of end users and providing many versions to users causing some issues.

Basically, this issue exists for 3 users. We can't reproduce this on any other computers. But these 3 users are 1% of test group - imagine roll-out to all users that counts with 100K.

None of affected users have outlook issue if plugin is disabled. For instance, they are working in outlook and outlook starts to slows down as per logs I provided. Closing outlook and opening outlook again DOES not fix the issue once its slow. Disabling addin does. We have tested this also with restarting a computer (or at least user said he did it as remotely is hard to make sure about this). User states that restart does not fix Outlook issue when issue exists.

Kind regards
Posted 10 Jan, 2018 12:19:40 Top
Andrei Smolin


Add-in Express team


Posts: 15353
Joined: 2006-05-11
Hello Jakub,

Gutek Jakub writes:
Closing outlook and opening outlook again DOES not fix the issue once its slow.


This description suggests that the issue doesn't belong to the code of the add-in. I'd try to reinstall Office for these users. Especially, if they belong to the same company. Make sure they have all updates on Office and windows.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 12 Jan, 2018 08:20:26 Top