[Exchange-Online] [EWSMA] [C#] [Windows] Search by multiple categories is broken for O365 RRS feed

  • Question

  • Hello,

    Our product uses multiple item categories to categorize appointments, contacts, emails, and tasks. It supports multiple business types which could be mapped to the same Exchange object type. For example, single Exchange appointment/meeting could have one or two categories: Sync + Visit, or Sync + Appointment, or just Sync and represent three different business types.

    The product supports Exchange 2010, 2013, 2016 and O365. It uses the same code base for building EWS search filters and further object processing. A separate search query is built for retrieving different types of business objects.

    Recently we discovered that server-side search by multiple categories has stopped working for O365 configurations while it works as before on our on-premise 2010, 2013, and 2016 Exchange servers. 

    Unfortunately we couldn't switch to AQS filters due to additional search filters being used for extended properties, ExcludesBitmask filter etc. Refactoring to do more client-side processing is too risky and requires too much effort. We consider it as a long-term option but now we must provide a hotfix to address the problem.

    This regress happened just few days ago. The following C# sample demonstrates the problem. Is there a quick way to make it working again?


    private static void FindByMultipleCategories(string ewsUrl, string userName, string password)
        ServicePointManager.ServerCertificateValidationCallback =
            (sender, certificate, chain, sslPolicyErrors) => true;
        var service = new ExchangeService(ExchangeVersion.Exchange2010_SP2)
            Url = new Uri(ewsUrl),
            Credentials = new WebCredentials(userName, password)
        const string subject = "Test object";
        const WellKnownFolderName folderId = WellKnownFolderName.Calendar;
        var item = new Appointment(service)
            Subject = subject
        // Add two test categories.
        // Now try finding this appointment by categories.
        // The following filter worked fine for Exchange 2010, 2013, 2016, and O365
        // until today. Now it stopped working for O365.
        // Cannot use AQS because of additional filters examining
        // extended properties and ExcludesBitmask for AppointmentState flag.
        // Additional filters omitted for clarity.
        var filter = new SearchFilter.SearchFilterCollection(
            new SearchFilter.IsEqualTo(ItemSchema.Categories, "Category1"),
            new SearchFilter.IsEqualTo(ItemSchema.Categories, "Category2"));
        var view = new ItemView(100)
            PropertySet = new PropertySet(BasePropertySet.IdOnly, ItemSchema.Subject)
        var findResults = service.FindItems(folderId, filter, view);
        if (findResults.TotalCount > 0 && findResults.Items.All(i => i.Subject == subject))
            Console.WriteLine("SUCCESS: find by multiple categories works as expected.");
                "ERROR: {0} items found in Exchange by multiple categories.",
        // Cleanup.

    Tuesday, June 12, 2018 2:02 PM