none
Item change event in outlook 2007 RRS feed

  • Question

  • Hi, all

    I met a strange problem in outlook 2007.

    I write a function(as A) to do reaction  with item change event so I can do something when appoinment change.

    But the strange thing is when I debug it, the program will first step into the A just after outlook open. It is not suppose to behavior like this becase nothing has changed with any appointment, I didn't even open any of the appointment.

     And it performs ok in run mode, but I need debug because I need to know where goes wrong in my code.

    If you know about it, please help me.

    Thanks to all.

    Tuesday, July 17, 2012 1:58 PM

Answers

  • The change event will fire for each change that occurs, and one change can end up affecting many others if calculated properties are involved. For example, and this is specific to contacts but occurs with other types of items, think of changing FirstName.
     
    When that's changed you also change FullName, FileAs, CompanyAndFullName, CompanyLastFirstNoSpace and about 10 or more other properties.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "SaraZC" <=?utf-8?B?U2FyYVpD?=> wrote in message news:096ec7cd-154d-483b-b4a7-de0f36fb1c01...

    I need to do something when appointmentitem change.

    I am now handling the item changing both in item save event and item change event, do you think it is right


    Ken Slovak MVP - Outlook
    • Marked as answer by SaraZC Sunday, July 22, 2012 9:55 AM
    Wednesday, July 18, 2012 1:40 PM
    Moderator
  • Drag and drop operations are not well covered in the object model. You need to do what you're doing with change on items, plus handling Items.ItemAdd() to cover when new items are dragged to a folder. 

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "SaraZC" <=?utf-8?B?U2FyYVpD?=> wrote in message news:e23eb048-c418-4147-9f91-d5375cf534a0...

    For example, I need to add my code when user drag an appointment(not meeting, without attendee) from one time to another time, how can I detected that?  What happend when user does this?

    I am now handling it with item change event, but it invoke many other problems, is there another way to hanlde with the draging?

    Thanks


    Ken Slovak MVP - Outlook
    • Marked as answer by SaraZC Sunday, July 22, 2012 9:55 AM
    Wednesday, July 18, 2012 2:46 PM
    Moderator

All replies

  • Can you show your code please?

    Eric Legault MVP (Outlook)
    About me...
    Try Outlook Appins - affordable and easy to use!

    Tuesday, July 17, 2012 2:09 PM
    Moderator
  • Hi, Eric,

    This is the main code about the event, it is supposed to be called only once if the item is being changed, but it is called for serveral times if I change a item, even when I didn't operate with an item.

    SINK_ENTRY_INFO(4, __uuidof(Outlook::ItemsEvents), 0xf002/*ItemChange*/, OnAppointmentItemChange, &ItemsInfo)
    void __stdcall OnAppointmentItemChange(IDispatch* pItem)
    {
        // here I do my thing
    }

    Wednesday, July 18, 2012 7:28 AM
  • in general all 'data' events (item add/change/remove) may be called at any time as outlook pleases. Sure they are called as a reaction to UI/code actions but those are not the only cases where this will happen.
    Wednesday, July 18, 2012 8:23 AM
  • Dear Damian,

    So you think they called the function for many times is normal situation?

    The times the function be called is not always the same, even with same operation. 

    And is it possible that outlook ends one function  in condition that the function doesn't exucute to the end?

    I feel confused because I didn't know the internal hierarchy of outlook.

    Thanks all of you for always answering my questions.

    Best Regards.

    Wednesday, July 18, 2012 9:20 AM
  • how many times it will be called is solely up to the outlook. You definietly should not depend on fact that itemchange will only fire once and as a response to your actions.
    Wednesday, July 18, 2012 12:37 PM
  • I need to do something when appointmentitem change.

    I am now handling the item changing both in item save event and item change event, do you think it is right

    Wednesday, July 18, 2012 1:02 PM
  • The change event will fire for each change that occurs, and one change can end up affecting many others if calculated properties are involved. For example, and this is specific to contacts but occurs with other types of items, think of changing FirstName.
     
    When that's changed you also change FullName, FileAs, CompanyAndFullName, CompanyLastFirstNoSpace and about 10 or more other properties.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "SaraZC" <=?utf-8?B?U2FyYVpD?=> wrote in message news:096ec7cd-154d-483b-b4a7-de0f36fb1c01...

    I need to do something when appointmentitem change.

    I am now handling the item changing both in item save event and item change event, do you think it is right


    Ken Slovak MVP - Outlook
    • Marked as answer by SaraZC Sunday, July 22, 2012 9:55 AM
    Wednesday, July 18, 2012 1:40 PM
    Moderator
  • For example, I need to add my code when user drag an appointment(not meeting, without attendee) from one time to another time, how can I detected that?  What happend when user does this?

    I am now handling it with item change event, but it invoke many other problems, is there another way to hanlde with the draging?

    Thanks

    Wednesday, July 18, 2012 2:05 PM
  • i do not think there is easy (in way of coding) answer for that. Either track selection and attach to propertychange event to detect that starttime property changed or go the way you already went with itemchange but detect somehow that properties important for you changed (either by storing them off-site or in custom props in item itself)
    Wednesday, July 18, 2012 2:27 PM
  • Drag and drop operations are not well covered in the object model. You need to do what you're doing with change on items, plus handling Items.ItemAdd() to cover when new items are dragged to a folder. 

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "SaraZC" <=?utf-8?B?U2FyYVpD?=> wrote in message news:e23eb048-c418-4147-9f91-d5375cf534a0...

    For example, I need to add my code when user drag an appointment(not meeting, without attendee) from one time to another time, how can I detected that?  What happend when user does this?

    I am now handling it with item change event, but it invoke many other problems, is there another way to hanlde with the draging?

    Thanks


    Ken Slovak MVP - Outlook
    • Marked as answer by SaraZC Sunday, July 22, 2012 9:55 AM
    Wednesday, July 18, 2012 2:46 PM
    Moderator