Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

EWS Search Query only returns 250 items from Archive Mailbox #284

@hpatel70

Description

@hpatel70

I have C# application which uses EWS Managed API (2.2.1.0)to perform search and collect data from Exchange servers. Recently client reported an issue where they noticed our application was only collecting 250 items from any folder from Archive Mailbox when user specified a date filter. We were able to replicate this issue with EWSEditor tool as well.

The following query returned all items from Archive Mailbox folder.

((Kind:Email) OR (Kind:Meetings) OR (Kind:Tasks) OR (Kind:Notes) OR (Kind:Docs) OR (Kind:Journals) OR (Kind:Contacts) OR (Kind:IM))

But the following query returned only 250 items from Archive Mailbox folders.

((Sent:1/1/1980..12/31/2022 OR Received:1/1/1980..12/31/2022)) AND
((Kind:Email) OR (Kind:Meetings) OR (Kind:Tasks) OR (Kind:Notes) OR (Kind:Docs) OR (Kind:Journals) OR (Kind:Contacts) OR (Kind:IM))

The application uses paging when making FindItems calls as shown below.

private List RetrieveItems(Folder folder, string query)
{
const int PAGE_SIZE = 500;

        List<Item> items = new List<Item>();
        int offset = 0;
        bool moreResults = false;

        do
        {
            ItemView view = new ItemView(PAGE_SIZE, offset);
            view.PropertySet = new PropertySet(EmailMessageSchema.Subject, EmailMessageSchema.LastModifiedTime, EmailMessageSchema.DateTimeCreated, EmailMessageSchema.Size, EmailMessageSchema.ItemClass, ItemSchema.HasAttachments);

            FindItemsResults<Item> results = null;
            Retry(() =>
            {
                results = folder.FindItems(query, view);
            });

            items.AddRange(results);

            offset += PAGE_SIZE;
            moreResults = results.MoreAvailable;
        }
        while (moreResults);

        return items;
    }

There are no restrictions on service account used for authentication per client. The issue is not seen when searching non Archive Mailbox folders.

Has anyone run into this restriction or know how to resolve this issue so we can get all matching items from Archive Mailbox folders?

Thanks,
Hiren Patel

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions