问题
I have place items on the calender (in the past), however the FindItems()
call is coming back with 0 results.
Code for the search
SearchFilter greaterthanfilter = new SearchFilter.IsGreaterThanOrEqualTo(ItemSchema.DateTimeReceived, start);
SearchFilter lessthanfilter = new
SearchFilter.IsLessThan(ItemSchema.DateTimeReceived, end);
SearchFilter filter = new
SearchFilter.SearchFilterCollection(LogicalOperator.And, greaterthanfilter, lessthanfilter);
ItemView view = new ItemView(100); //TODO: This value needs to be set based on the date range criteria
ExtendedPropertyDefinition prop = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.Appointment, 0x8238, MapiPropertyType.String);
PropertySet psPropset = new PropertySet(BasePropertySet.FirstClassProperties) { AppointmentSchema.Subject, AppointmentSchema.Organizer, prop };
view.PropertySet = psPropset;
view.OrderBy.Add(ItemSchema.DateTimeReceived, Microsoft.Exchange.WebServices.Data.SortDirection.Descending);
view.Traversal = ItemTraversal.Shallow;
findResults = this.exchangeService.FindItems(new FolderId(WellKnownFolderName.Calendar, new Mailbox(address.Address)), filter, view);
The start and ends dates are fed in via the parameters of the method. I have breakpointed there and ensured the dates are
Start - 1/6/2014 12 am
End - 1/8/2014 12 am
However the findResults
are always empty (count is 0).
回答1:
If you want to search for calendar Items then using the DateTimeReceived isn't the correct property to use. You should use AppointmentSchema.Start the DateTimeRecieved on the appointment would represent more when the appointment was created not when they are scheduled to start.
If you want to enumerate calendar appointments based on a date range then you should use FindAppointments http://msdn.microsoft.com/en-us/library/office/dn439786(v=exchg.80).aspx . The difference here is that the recurring appointments will be expanded as well.
Cheers Glen
来源:https://stackoverflow.com/questions/23960601/ews-finditems-not-working