我以这种方式添加扩展属性:
ExtendedPropertyDefinition ep = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.CalendarAssistant, "AppointmentID", MapiPropertyType.Integer);
Appointment newApp = new Appointment(service);
newapp.SetExtendedProperty(ep, appID);
newApp.Save(SendInvitationsMode.SendToNone);
一切都很好。预约按预期显示在Outlook中。
稍后,我尝试使用由以下人员分配的约会ID搜索所有Outlook约会:
List<SearchFilter> filters = new List<SearchFilter>();
filters.Add(new SearchFilter.Exists(ep));
filters.Add(new SearchFilter.IsLessThan(AppointmentSchema.Start, DateTime.Now.AddDays(60)));
filters.Add(new SearchFilter.IsGreaterThanOrEqualTo(AppointmentSchema.Start, DateTime.Today));
FindItemsResults<Item> allOutlookAppt = service.FindItems(WellKnownFolderName.Calendar, new SearchFilter.SearchFilterCollection(LogicalOperator.And, filters.ToArray()), viewFind);
allOutlookAppt返回预期的集合(设置了AppointmentID的日历条目)。但是我无法通过此代码检索AppointmentID:
foreach (var a in allOutlookAppt) // contains correct calendar entries!
{
object oid;
if (a.TryGetProperty(ep, out oid))
{
// a.TryGetProperty is always false, oid is always null thus never enter here!
}
}
我做错了什么?
编辑:我尝试过.ExtendedProperties.Count,它实际上返回0。
答案 0 :(得分:1)
谷歌搜索后,我必须在搜索日历之前添加它
viewFind.PropertySet = new PropertySet(ep);