EWS FindItems not working

老子叫甜甜 提交于 2019-12-25 17:01:31

问题


I have place items on the calender (in the past), however the FindItems() call is coming back with 0 results.

Screenshot to show there are meetings scheduled for this Room Mailbox for the desired date

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!