EWS托管API,基于ICalUid进行搜索

时间:2017-01-03 06:15:52

标签: c# exchangewebservices ews-managed-api

Appointment newAppointment = new Appointment(service);

newAppointment.Subject = "Test Subject";
newAppointment.Start = new DateTime(2017, 01, 05, 17, 00, 0);
newAppointment.StartTimeZone = TimeZoneInfo.Local;
newAppointment.EndTimeZone = TimeZoneInfo.Local;
newAppointment.End = newAppointment.Start.AddMinutes(30);
newAppointment.ICalUid = "asdasda=";
newAppointment.Save();
newAppointment.Body = new MessageBody(BodyType.Text, "test");
newAppointment.RequiredAttendees.Add("abc@domain.com");

newAppointment.Update(ConflictResolutionMode.AlwaysOverwrite, SendInvitationsOrCancellationsMode.SendOnlyToAll);

ExtendedPropertyDefinition CleanGlobalObjectId = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.Meeting, "ICalUid", MapiPropertyType.String);
PropertySet psPropSet = new PropertySet(BasePropertySet.FirstClassProperties);
psPropSet.Add(CleanGlobalObjectId);
newAppointment.Load(psPropSet);

Folder AtndCalendar = Folder.Bind(service, new FolderId(WellKnownFolderName.Calendar, "abc@domain.com"));
SearchFilter sfSearchFilter = new SearchFilter.IsEqualTo(CleanGlobalObjectId, "asdasda=");
ItemView ivItemView = new ItemView(1);

FindItemsResults < Item > fiResults = AtndCalendar.FindItems(sfSearchFilter, ivItemView);

if (fiResults.Items.Count > 0) {
 //do whatever
}

这对我不起作用。而且我不想使用下面的代码,我们遍历日历视图。在很多地方搜索并尝试了很多代码。

EWS没有关于此的文档。任何形式的帮助将不胜感激。

DateTime startDate = new DateTime(2016, 10, 1);
DateTime endDate = new DateTime(2017, 12, 1);
CalendarView calView = new CalendarView(startDate, endDate);

3 个答案:

答案 0 :(得分:0)

如果内存有效,则无法基于ICalUid进行搜索。我认为部分原因是因为它不一定是唯一的,尽管它的名字。例如。如果您开会并邀请两个房间,ICalUid对于两个房间的约会是相同的。日历和你的日历。

为什么不从你保存的约会中挑选出ItemId?我想除了您在示例代码中显示的内容之外,还有其他一些原因吗?

答案 1 :(得分:0)

为什么不在你的代码中使用你定义错误的CleanGlobalObjectId(你使用的定义不会返回任何内容),而不是IcalUid,它是一种无法搜索的强类型属性。例如EWS - Given an Appointment, get the owner's copy of the Appointment

答案 2 :(得分:-1)

使用扩展属性。

ExtendedPropertyDefinition def = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.PublicStrings, APPOINTMENTIDEXTENDPROPNAME, MapiPropertyType.String);
相关问题