2013-02-09 98 views
0

我需要在约会实例的约会约会的主人上设置UserProperty。如何修改AppointmentItem.Parent对象

该场景是: a。用户打开定期会议/约会的实例。 b。我的程序在预约系列的主设备上设置UserProperty

使用Parent属性获取主约会很容易,但是它是只读的。

如何获得对主约会的可修改引用?

我想执行的代码是沿着这些线路

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

回答

1

是什么让你认为AppointmentItem.Parent返回只读AppointmentItem?
当你打电话保存时你有错误吗?
如果您需要添加自定义属性,请使用AppointmentItem.UserProperties.Add。

+0

我没有注意到它,但MSDN文档说它是AppointmentItem上的只读属性。当我尝试在父项上添加用户proprety时,我得到一个异常: – Marcin 2013-02-10 03:16:30

+0

但是你说得对 - 我在那段代码中遇到异常,我认为是什么导致了它,但事实并非如此。 – Marcin 2013-02-10 06:32:31

+0

从某种意义上说,它是只读的,您无法设置它:例如(AppointmentItem.Parent = SomeOtherFolder)将不起作用。但从Parent属性返回的对象是可编辑的,除非当前用户对约会所在的文件夹具有只读权限。你正在得到什么确切的错误? – 2013-02-10 17:50:38