none
O365 returning 0 found items when total item count of subfolders is high RRS feed

  • Question

  • Hello all,

    Have been using EWS since 2007, originally unmanaged C# and now v2 of the Managed API.

    BACKGROUND: When using a very basic FindItems request against WellKnownFolderName.Inbox, O365 has been returning 0 found items (as a successful search) when the Inbox does indeed contain a number of emails.

    SPECIFICS: Inbox has 2 subfolders within it. The item count of these subfolders can become quite high (around 90000+ emails) although the total mailbox size is well within limits (~9GB out of allowed 100GB). At a certain point, with about 10 or so new emails in the top level of the Inbox, O365 has been returning a successful search result but showing an item count of 0. ItemView on the search has been set at 5, 10 , 50 , 100 all with the same result. OWA (or whatever it's name is this afternoon) shows the emails. The FindItemsResults returned by O365 is exactly the same as it would be if the Inbox did indeed contain 0 emails, which means users do not know the issue actually exists until they believe it's been too long since an email was received.

    Deleting emails from the subfolders (reducing the total count down to around 65000) and O365 returns the correct results.

    WORKAROUND: We do not want to have to delete all these emails. They are kept in the folder structure for a reason. We are currently storing a known email in the top level of the inbox but not showing it in user results. This means that if O365 ever returns a find count of 0 we know there is an issue (as that 1 marker email should always be there). This lets us know there is an issue, but doesn't actually solve the root problem.

    NICE TO KNOW: Are there published item count maximums for a folder / sub folder structure that should not be exceeded? Short of archiving these emails, is there another better fix? As the application grows (10 years and growing every day), the retention (currently 6 months) of emails in this folder structure doesn't really need to change, but the item count for said retention will continue to grow.

    INTERESTINGLY: The move to O365 happened recently. Prior to this the exact same code was running against on-prem Exchange server. This would always return the correct search results, but would go from reasonably fast to VERY slow in returning the results once the item count reached a certain limit. It was pretty obvious to the user when this happened, as mailbox (of our own application) refreshes would change from ~1 second to ~20 seconds.

    EWS limits have always been somewhat of a grey area, but now with O365 they just don't exist. We were hitting limits on the account at one stage (locking the account out for 5 minutes each time) and were told that our usage limits have been increased from 'something' to 'something more than something but definitely enough'. I wish I could write code in those terms. Microsoft tell me that they will not divulge the limits through fear of misuse, but they are heavily enforced. This is somewhat akin to being fined for speeding in a car, even though the speed limit is not published and the officer giving the ticket will not tell you either. Hey ho.

    Any pointers would be very much appreciated.

    Thanks.

    Tuesday, June 20, 2017 2:37 PM

All replies

  • You might want to try testing this using the EWSeditor https://ewseditor.codeplex.com/

    The limit on the total number of Items in a folder is 1 million https://technet.microsoft.com/en-au/library/exchange-online-limits.aspx I've seen EWS working on a 1 million item folder in Office365 but the mailbox is pretty much unusable at that state (eg generally won't open in Outlook).

    A few things you have said don't really make sense eg firstly OWA uses a EWS FindItem under the covers (just use the developer tools in browser and have a look at the underlying requests) so if OWA is working and you app isn't then I would be looking at your code or query. Also subfolder Item counts won't affect the parent folder as contextly a FindItem request will only traverse the folder your querying. If you post the code your using and the results from using the EWSeditor that may help somebody looking at your issue.

    Cheers
    Glen  

    Wednesday, June 21, 2017 4:04 AM
  • Super, thanks for the reply Glen. The issue has yet to recur (the email counts are slowly creeping up).

    When the issue was happening I actually wrote a piece of simple as possible test code to double check the results:

    ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013_SP1);

    service.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");

    service.Credentials = new NetworkCredentials(valid user, pass & domain);

    FindItemsResults<Item> findResults = null;

    try
    {
        findResults = service.FindItems(WellKnownFolderName.Inbox, new ItemView(100));
    }
    catch (Exception exc)
    {
        Console.WriteLine(exc.Message);
    }

    at this point the search result is success and the item count is 0. OWA responding fine and showing the emails (there are never more than 20 or so emails at the top level of the Inbox).

    As mentioned, clearing out an amount of emails from the 2 sub folders immediately resolves the issue.

    I will endeavour to create a copy of this mailbox to try and replicate the issue and then follow your advice. Very difficult for me to conduct extensive tests on it while it is in a "broken" state, being a production environment.

    Thanks again.


    Thursday, June 22, 2017 6:09 AM