none
ItemEvents_10_PropertyChangeEventHandler Not Firing RRS feed

  • Question

  • Hello all,

     

    Maybe you can help me to understand if I'm doing something wrong - 

    I got an Outlook Plugin with the following code:

     

     

    private void ThisAddIn_Startup(object sender, System.EventArgs e)
            {
               this.Application.Inspectors.NewInspector += new Outlook.InspectorsEvents_NewInspectorEventHandler(inspectors_NewInspector);
            }
    
    void inspectors_NewInspector(Outlook.Inspector Inspector)
            {
               if (Inspector.CurrentItem is Outlook.AppointmentItem)
                {
                    AppointmentItem appointmentItem = Inspector.CurrentItem as AppointmentItem;
                   appointmentItem.PropertyChange += new ItemEvents_10_PropertyChangeEventHandler(currentAppoitment_PropertyChange);
                }
            }
    
    void currentAppoitment_PropertyChange(string Name)
            {
    MessageBox.Show("I was changed..." + Name);
            }
    

     


    The problem is that this message box is not always showing :(

    Usually, after Outlook starts and I open the item for the first time it doesn't.

    But, when I close it and open it for the second time - it works fine - any property changed shows a message box.

    And ofcourse I'm talking about the same item.

    I'm on outlook 2010 by the way if that matters.


    • Edited by gurdziev Wednesday, December 28, 2011 12:34 PM Code fix
    • Changed type gurdziev Wednesday, December 28, 2011 12:35 PM
    Wednesday, December 28, 2011 12:32 PM

Answers

  • Hi, thnaks for your reply.

    Actually I figured it out - 

    The plugin was ofcourse loading,

    the problem is the for some reason GC was collecting the appointments...

    I created a local variable List<AppointmentItem> that kept all those appoitments.

    It's an ugly solution, will probably take too much memory if outlook will be kept open for a long time, but it works.

    I will keep digging - maybe I will find some event where I can release the reference to the unloading appointment....

    Anyway - thanks again for your input.

    • Marked as answer by gurdziev Monday, January 2, 2012 8:42 AM
    Monday, January 2, 2012 8:41 AM

All replies

  • Could you verify the addin loads at the first time?

    In my test lab machine, debugging the addin, the message box will always appear when any property changed.

    To check the addin loading status, you can open Com-Addin dialog of Outlook and verify there.

    Please let me know if there's anything unclear, I'll try my best to help.


    Forrest Guo | MSDN Community Support | Feedback to us


    Friday, December 30, 2011 9:55 AM
    Moderator
  • Hi, thnaks for your reply.

    Actually I figured it out - 

    The plugin was ofcourse loading,

    the problem is the for some reason GC was collecting the appointments...

    I created a local variable List<AppointmentItem> that kept all those appoitments.

    It's an ugly solution, will probably take too much memory if outlook will be kept open for a long time, but it works.

    I will keep digging - maybe I will find some event where I can release the reference to the unloading appointment....

    Anyway - thanks again for your input.

    • Marked as answer by gurdziev Monday, January 2, 2012 8:42 AM
    Monday, January 2, 2012 8:41 AM