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

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

Open
hpatel70 opened this issue Jul 14, 2022 · 5 comments
Open

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

hpatel70 opened this issue Jul 14, 2022 · 5 comments

Comments

@hpatel70
Copy link

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

@hpatel70
Copy link
Author

Anyone ran into this issue and know how to fix it?

@timanderson
Copy link

@MichelZ
Copy link

MichelZ commented Aug 24, 2022

Note: https://devblogs.microsoft.com/microsoft365dev/upcoming-changes-to-exchange-web-services-ews-api-for-office-365/

Microsoft has abandoned us, it seems.

Tim

What gave you that impression?
The fact that they announced it 4 years ago?

"Starting July 19th 2018, Exchange Web Services (EWS) will no longer receive feature updates. "

@timanderson
Copy link

True, but do you know any other way to access public folders on Exchange Online programmatically?

Tim

@MichelZ
Copy link

MichelZ commented Aug 24, 2022

I don't, and a lot of other functionality is also missing in Graph (the "replacement" for EWS). But Microsoft clearly said that this project here is dead, so we're on our own :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants