How to modify the AppointmentItem.Parent object

2019-09-05 08:38发布

问题:

I need to set a UserProperty on a master of a recurring Appointment, from an appointment instance.

The scenario is: a. user opens an instance of a recurring meeting/appointment.
b. my program sets a UserProperty on the master of the appointment series

Getting the master appointment is easy with the Parent property, however it is read-only.

How can I get a modify-able reference to the master appointment?

The code I want to execute is along these lines

Outlook.AppointmentItem masterAppointment = (Outlook.AppointmentItem)(currentAppointment.Parent);
masterAppointment.ItemProperties.Add("xxx", Outlook.OlUserPropertyType.olText);
masterAppointment.ItemProperties["xxx"].Value = aStringValue;
masterAppointment.Save();

回答1:

What makes you think that AppointmentItem.Parent returns a read-only AppointmentItem?
Do you get an error when you call Save?
If you need to add a custom property, use AppointmentItem.UserProperties.Add.