none
Item Send event - Addin processing order if multiple different addins installed that execute code on this event RRS feed

  • Question

  • Hi,

    I was wondering if there is a way to chose when a particular addin calls it's event if another addin works off the same event?  The particular example is I am writing an addin that searches for particular words in an email when the user presses the Send button.  The words it is searching for are automatically added by another 3rd party addin on the same Send event.

    Obviously my addin would not work if the 3rd party addin hasn't added the words I am looking for yet, so I need a way to make sure my addin runs last. Is there anyway of ensuring this?  If not, is there any other known solution for this sort of problem?

    Many thanks,

    Tom

    Wednesday, November 5, 2014 3:29 PM

Answers

  • > If at runtime (is this addin load event?), I check for this 3rd party addin in COMAddins property and find it is there, what do I do next?

    In that case there is a chance that the add-in subscribed to the ItemSend event.

    > Does the fact that it is already there mean it was loaded into Outlook first, and therefore executes first always?

    It was loaded first, but nobody knows when it is subscribed to the events. In most cases the job is done at the loading stage.  

    > if it was loaded into Outlook first then my addin was loaded second, on the item Send event it will always do it's operation first before mine?

    Theoretically, yes. But as I said earlier, nobody can guarantee the order. I'd suggest testing it first.

    Wednesday, November 5, 2014 4:50 PM

All replies

  • Hello Tom,

    No, the Outlook extensibility model (nor Office) doesn't provide anything for managing the order in which they are loaded. However, at runtime you can check the list of installed and active add-ins (see the COMAddins property of the Application class) and only then subscribe to the ItemSend event. I think in that case you will handle the event later than other add-ins (subscribed to the events earlier).

    Wednesday, November 5, 2014 3:36 PM
  • Hi Eugene,

    Thanks for your response.  I'm not sure if I completely understand though... when you say at runtime I can check the list of installed and active addins at run time, is this on the addin Load event I do this?  What exactly am I checking for also?  Finally, when you say "only then subscribe to the ItemSend event", what do you mean by this?

    To clarify my situation:

    Our addin checks for words that a third party addin adds to an email before sending.  This 3rd party addin we don't necessarily know what it is called, but we can assume that it is always installed and running.  On the item Send event, the 3rd party addin will add these words, and on that same event our addin has to check for specific ones (e.g. whether one of the words it has added is a keyword in a database that we are checking against).  Obviously our addin always needs to do the check on item send after the 3rd party addin has added the keywords... so we need a way on ensuring that it always is last in the execution order.

    Is you proposed solution something that will work for this?

    Thanks again for helping!

    Cheers,

    Tom

    Wednesday, November 5, 2014 3:45 PM
  • Tom,

    In theory, yes. It is supposed to work.

    But you can't be sure that your add-in is loaded after all other add-ins. Typically in the .Net world events are fired using the FIFO queue. But nobody guarantees that in case of Outlook you get the same results. So, to check that, at runtime you can try to find the add-in which adds words to items. If it's loaded and enabled you can subscribe to the ItemSend event.  

    Wednesday, November 5, 2014 3:57 PM
  • Hi Eugene,

    I'm still not completely understanding how your solution might work, sorry if I'm missing something here...

    I don't necessarily know which 3rd party addin is being used to add these words, so I won't be able to check for it by name... but ignoring that for now, I want to understand the second part of your answer.

    If at runtime (is this addin load event?), I check for this 3rd party addin in COMAddins property and find it is there, what do I do next?  Does the fact that it is already there mean it was loaded into Outlook first, and therefore executes first always? i.e. if it was loaded into Outlook first then my addin was loaded second, on the item Send event it will always do it's operation first before mine?

    Thanks,

    Tom

    Wednesday, November 5, 2014 4:08 PM
  • > If at runtime (is this addin load event?), I check for this 3rd party addin in COMAddins property and find it is there, what do I do next?

    In that case there is a chance that the add-in subscribed to the ItemSend event.

    > Does the fact that it is already there mean it was loaded into Outlook first, and therefore executes first always?

    It was loaded first, but nobody knows when it is subscribed to the events. In most cases the job is done at the loading stage.  

    > if it was loaded into Outlook first then my addin was loaded second, on the item Send event it will always do it's operation first before mine?

    Theoretically, yes. But as I said earlier, nobody can guarantee the order. I'd suggest testing it first.

    Wednesday, November 5, 2014 4:50 PM
  • Hello Tom and Eugene (glad to meet you again :)

    To the best of my knowledge add-ins are loaded in the alphabetical order of their ProgIDs. In a test (sorry, I can't remember details), an event was given to the add-ins being tested in the reverse order. I suggest that you create a test add-in to verify this.


    Regards from Belarus (GMT + 3),

    Andrei Smolin
    Add-in Express Team Leader

    Please mark answers and useful posts to help other developers use the forums efficiently.

    Thursday, November 6, 2014 10:48 AM
  • It confirms my assumptions that such things should be tested carefully.

    Nobody guarantees the order of loading add-ins and events fired. I have never seen such docs.

    Thursday, November 6, 2014 11:12 AM