0

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

enter image description here 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).

owen gerig
  • 6,165
  • 6
  • 52
  • 91
  • Have you tried it without the filter? – eddie_cat May 30 '14 at 17:54
  • I get 17 items back (not a heavily used room mailbox, this is all in a test environment). But nothing prior to 5/20. It seems to me like its ignoring meetings that are created in the "past". Meaning had i created this 1/7 meeting on 1/6 it would have found it, but since i created it today its not seeing it. however the point of the feature im working on is to synchronize between prior dates and so the only way i can test is to create appointments in the past – owen gerig May 30 '14 at 18:18

1 Answers1

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

Glen Scales
  • 20,495
  • 1
  • 20
  • 23