这是我从EWS获取一些日历项目(约会)的代码。但这始终是一个例外。
例外情况: - 此属性不能与此类限制一起使用。
private void GetChangedAppointmentInformation(Appointment appointment)
{
try
{
// Save appointment details into local variables
id = appointment.Id.ToString();
body = appointment.Body;
duration = appointment.Duration;
end = appointment.End;
bookingKey = appointment.Subject;
subject = appointment.Subject;
location = appointment.Location;
ItemView view = new ItemView(1000);
// Create a search filter that filters email based on the existence of the extended property.
SearchFilter eq = new SearchFilter.IsEqualTo(AppointmentSchema.ICalUid, appointment.ICalUid);
// Search the Calendar with the defined view and search filter. This results in a FindItem operation call to EWS.
FindItemsResults<Item> findResults = service.FindItems(WellKnownFolderName.Calendar, eq, view);
}
catch (Exception ex)
{
Console.WriteLine("Error: " + ex.Message);
}
}
你能就此提出建议吗?我尝试了MSDN和其他几个在线资源,我还在试图解决这个问题。
答案 0 :(得分:3)
错误告诉您,您尝试使用的强类型属性无法在限制中使用。解决此问题的最佳解决方法是使用等效的扩展属性,例如,基于现有约会进行搜索,例如
Appointment newAppointment = new Appointment(service);
newAppointment.Subject = "Test Subject";
newAppointment.Start = new DateTime(2012, 03, 27, 17, 00, 0);
newAppointment.StartTimeZone = TimeZoneInfo.Local;
newAppointment.EndTimeZone = TimeZoneInfo.Local;
newAppointment.End = newAppointment.Start.AddMinutes(30);
newAppointment.Save();
newAppointment.Body = new MessageBody(Microsoft.Exchange.WebServices.Data.BodyType.Text, "test");
newAppointment.RequiredAttendees.Add("attendee@domain.com");
newAppointment.Update(ConflictResolutionMode.AlwaysOverwrite ,SendInvitationsOrCancellationsMode.SendOnlyToAll);
ExtendedPropertyDefinition CleanGlobalObjectId = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.Meeting, 0x23, MapiPropertyType.Binary);
PropertySet psPropSet = new PropertySet(BasePropertySet.FirstClassProperties);
psPropSet.Add(CleanGlobalObjectId);
newAppointment.Load(psPropSet);
object CalIdVal = null;
newAppointment.TryGetProperty(CleanGlobalObjectId, out CalIdVal);
Folder AtndCalendar = Folder.Bind(service, new FolderId(WellKnownFolderName.Calendar,"attendee@domain.com"));
SearchFilter sfSearchFilter = new SearchFilter.IsEqualTo(CleanGlobalObjectId, Convert.ToBase64String((Byte[])CalIdVal));
ItemView ivItemView = new ItemView(1);
FindItemsResults<Item> fiResults = AtndCalendar.FindItems(sfSearchFilter, ivItemView);
if (fiResults.Items.Count > 0) {
//do whatever
}
应该可以正常工作
干杯 格伦