从 Exchange/Outlook 约会延长 属性
Getting extended property from Exchange/Outlook appointment
我这样加一个扩展的属性:
ExtendedPropertyDefinition ep = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.CalendarAssistant, "AppointmentID", MapiPropertyType.Integer);
Appointment newApp = new Appointment(service);
newapp.SetExtendedProperty(ep, appID);
newApp.Save(SendInvitationsMode.SendToNone);
一切都很好。约会按预期显示在 Outlook 中。
后来我尝试搜索所有 Outlook 约会,其约会 ID 分配给:
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 returns 预期集合(设置了 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!
}
}
我做错了什么?
编辑:我试过 a.ExtendedProperties.Count 结果实际上是 returns 0.
在谷歌搜索了一下之后,我必须在搜索日历之前添加这个
viewFind.PropertySet = new PropertySet(ep);
我这样加一个扩展的属性:
ExtendedPropertyDefinition ep = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.CalendarAssistant, "AppointmentID", MapiPropertyType.Integer);
Appointment newApp = new Appointment(service);
newapp.SetExtendedProperty(ep, appID);
newApp.Save(SendInvitationsMode.SendToNone);
一切都很好。约会按预期显示在 Outlook 中。
后来我尝试搜索所有 Outlook 约会,其约会 ID 分配给:
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 returns 预期集合(设置了 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!
}
}
我做错了什么?
编辑:我试过 a.ExtendedProperties.Count 结果实际上是 returns 0.
在谷歌搜索了一下之后,我必须在搜索日历之前添加这个
viewFind.PropertySet = new PropertySet(ep);