2017-01-03 126 views
0
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("[email protected]"); 

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, "[email protected]")); 
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托管API,基于ICalUid搜索

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

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

回答

0

如果内存服务,则无法基于ICalUid进行搜索。我认为部分原因是因为它不一定是唯一的,尽管它的名字。例如。如果您开会并邀请两个房间,那么ICalUid对于两个房间日历中的预约以及您的预约都是相同的。

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

-1

使用扩展属性。

ExtendedPropertyDefinition def = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.PublicStrings, APPOINTMENTIDEXTENDPROPNAME, MapiPropertyType.String);