none
Recurring Appointments/Meetings - Saving UserProperties Doesn't work RRS feed

  • Question

  • Hi Guys,

    I have the issue below, any help would be really appreciated!

    The Aim

    When a user creates or saves a new Appointment or Meeting or Reccuring Meeting, I want to set a UserProperties with some unique data.

    Current Situation

    I currently have a Appointment Inspector class which has an Item_Write event subscriber that is triggered when the user clicks on Save or Send etc. I am able to set the UserProperties property within this. 

    Within the Outlook Addin.cs, I am monitoring all ItemAdded & ItemChanged events on the Calendar Folder. These trigger as expected when any appointment or meeting is created. 

    The Problem

    The functionality works fine for single appointments but doesn't Recurring Appointments/Meetings. When I set the UserProperties property within the Item_Write, I want it to happen to all occurances.

    I have checked the User Property value within the ItemAdded & ItemChanged events, which execute after the Appointment Item_Write. And it seems that the property is NULL.

    Any ideas?

    Thursday, March 12, 2015 6:53 PM

Answers

  • Hello,

    If you need to add the same user property to all occurences of the recurring appointments/meetings you can use the GetRecurrencePattern  method which returns a RecurrencePattern object that represents the recurrence attributes of an appointment. The RecurrencePattern class provides the GetOccurrence method which returns a specific instance of the AppointmentItem object on the specified date where  you can add a user property.


    Also you may consider setting the property on the parent appointment item for the series. The Parent property of the ApointmentItem returns the parent AppointmentItem for the recurring instances and exceptions.
    • Edited by Eugene Astafiev Thursday, March 12, 2015 7:07 PM
    • Marked as answer by soledev Thursday, March 12, 2015 9:11 PM
    Thursday, March 12, 2015 7:04 PM
  • Eugene, today is not your day, sorry :-)

    If you want to add a user property to all instances of an appointment, you need to work with the master appointment (RecurrenceState ==  OlRecurrenceState.olApptMaster) returned from AppointmentItem.Parent if you are given an occurrence (RecurrenceState  == OlRecurrenceState.olApptOccurrence)


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!


    Thursday, March 12, 2015 7:09 PM

All replies

  • In case of an occurrence, do you set the properties on the appointment itself or its parent (which is another appointment)?

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Thursday, March 12, 2015 7:02 PM
  • Hello,

    If you need to add the same user property to all occurences of the recurring appointments/meetings you can use the GetRecurrencePattern  method which returns a RecurrencePattern object that represents the recurrence attributes of an appointment. The RecurrencePattern class provides the GetOccurrence method which returns a specific instance of the AppointmentItem object on the specified date where  you can add a user property.


    Also you may consider setting the property on the parent appointment item for the series. The Parent property of the ApointmentItem returns the parent AppointmentItem for the recurring instances and exceptions.
    • Edited by Eugene Astafiev Thursday, March 12, 2015 7:07 PM
    • Marked as answer by soledev Thursday, March 12, 2015 9:11 PM
    Thursday, March 12, 2015 7:04 PM
  • Eugene, today is not your day, sorry :-)

    If you want to add a user property to all instances of an appointment, you need to work with the master appointment (RecurrenceState ==  OlRecurrenceState.olApptMaster) returned from AppointmentItem.Parent if you are given an occurrence (RecurrenceState  == OlRecurrenceState.olApptOccurrence)


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!


    Thursday, March 12, 2015 7:09 PM
  • I don't see anything wrong in my post.
    Thursday, March 12, 2015 7:14 PM
  • Your code will create an exception from each and every occurrence... And think about appointments with no end date...

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Thursday, March 12, 2015 8:16 PM
  • I've already figured this out and added the suggestion to use the Parent property to the answer.
    Thursday, March 12, 2015 8:20 PM
  • Thanks Dmitry/Eugene , resolved the issue.

    I have marked both your posts as the answer as they both played a valudable contribution towards the resolution

    Thursday, March 12, 2015 9:13 PM