Microsoft.Exchange.WebServices.Data.ServiceValidationExcepti
本文关键字:ServiceValidationExcepti Data WebServices Exchange Microsoft | 更新日期: 2023-09-27 17:59:01
我正在从EWS日历访问约会参与者。我试过了:
cView.PropertySet = new PropertySet(AppointmentSchema.Subject,
AppointmentSchema.Start,
AppointmentSchema.End);
但我的appointments
列表条目中的每个条目都返回了空的Required/Optional Attendees字段,尽管测试预约已经被几个用户接受。我的假设是PropertySet需要包括更多的ApplicationSchema
属性,比如:
cView.PropertySet = new PropertySet(AppointmentSchema.Subject,
AppointmentSchema.Start,
AppointmentSchema.End,
AppointmentSchema.RequiredAttendees,
AppointmentSchema.OptionalAttendees);
但是,这会在日历上引发以下ServiceValidationException错误。FindAppointments(cView):
Microsoft.Exchange.WebServices.Data.ServiceValidationException:在FindItem请求中不能使用RequiredAdees属性。
如何解决此问题,使appointments
包含必需/可选的与会者?
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.Credentials = new WebCredentials(emailAddress, emailPassword);
// Initialize values for the start and end times, and the number of appointments to retrieve.
DateTime startDate = DateTime.Now;
DateTime endDate = startDate.AddYears(1);
const int NUM_APPTS = 4;
// Initialize the calendar folder object with only the folder ID.
CalendarFolder calendar = CalendarFolder.Bind(service, WellKnownFolderName.Calendar, new PropertySet());
// Set the start and end time and number of appointments to retrieve.
CalendarView cView = new CalendarView(startDate, endDate, NUM_APPTS);
// Limit the properties returned to the appointment's subject, start time, and end time.
cView.PropertySet = new PropertySet(AppointmentSchema.Subject,
AppointmentSchema.Start,
AppointmentSchema.End,
AppointmentSchema.RequiredAttendees,
AppointmentSchema.OptionalAttendees);
// Retrieve a collection of appointments by using the calendar view.
FindItemsResults<Appointment> appointments = calendar.FindAppointments(cView);
收件人是FindItems操作未返回的属性和正文之一,您需要使用GetItem请求来获取这些属性。请参阅https://msdn.microsoft.com/en-us/library/bb508824.aspx和https://blogs.msdn.microsoft.com/exchangedev/2010/03/16/loading-properties-for-multiple-items-with-one-call-to-exchange-web-services/