title: EWS FindItem CalendarView weird handling of MaxEntriesReturned
body: <p>This is my SOAP FindItem call to retrieve calendar items:</p>
  
  <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:mes="http://schemas.microsoft.com/exchange/services/2006/messages"&gt;
     &lt;soapenv:Header&gt;
        &lt;typ:RequestServerVersion Version="Exchange2007_SP1"/&gt;
        &lt;typ:MailboxCulture&gt;en-US&lt;/typ:MailboxCulture&gt;
        &lt;typ:TimeZoneContext&gt;
          &lt;typ:TimeZoneDefinition Id="W. Europe Standard Time"/&gt;
        &lt;/typ:TimeZoneContext&gt;
     &lt;/soapenv:Header&gt;
     &lt;soapenv:Body&gt;
        &lt;mes:FindItem Traversal="Shallow"&gt;
           &lt;mes:ItemShape&gt;
              &lt;typ:BaseShape&gt;AllProperties&lt;/typ:BaseShape&gt;
              &lt;typ:AdditionalProperties&gt;
                &lt;typ:FieldURI FieldURI="item:LastModifiedTime" /&gt;
              &lt;/typ:AdditionalProperties&gt;
           &lt;/mes:ItemShape&gt;
           &lt;mes:CalendarView MaxEntriesReturned="1000" StartDate="2015-02-18T00:00:00Z" EndDate="2015-12-05T23:59:59Z"/&gt;
           &lt;mes:ParentFolderIds&gt;
             &lt;typ:DistinguishedFolderId Id="calendar"&gt;
               &lt;typ:Mailbox&gt;
                 &lt;typ:EmailAddress&gt;sddress@server.nl&lt;/typ:EmailAddress&gt;
               &lt;/typ:Mailbox&gt;
             &lt;/typ:DistinguishedFolderId&gt;
          &lt;/mes:ParentFolderIds&gt;
        &lt;/mes:FindItem&gt;
     &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>The MaxEntriesReturned in the optional element </p>
  
  <pre><code> &lt;mes:CalendarView MaxEntriesReturned="1000" StartDate="2015-02-18T00:00:00Z" EndDate="2015-12-05T23:59:59Z"/&gt;
  </code></pre>
  
  <p>is supposed to mean <a href="https://msdn.microsoft.com/en-us/library/aa564515%28v=exchg.80%29.aspx" rel="nofollow">the maximum number of results to return in the FindItem response</a></p>
  
  <p>However:</p>
  
  <p>1) The results easily returns more items:</p>
  
  <pre><code>&lt;m:FindItemResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"&gt;
     &lt;m:ResponseMessages&gt;
        &lt;m:FindItemResponseMessage ResponseClass="Success"&gt;
           &lt;m:ResponseCode&gt;NoError&lt;/m:ResponseCode&gt;
           &lt;m:RootFolder TotalItemsInView="2516" IncludesLastItemInRange="false"&gt;
              &lt;t:Items&gt;
                 &lt;t:CalendarItem&gt;
  </code></pre>
  
  <p>(and note the <code>IncludesLastItemInRange="false"</code>, so there are more items. Then why return 2516?)</p>
  
  <p>2) If I leave <code>MaxEntriesReturned="1000"</code> out of the query, I get a <code>ErrorServerBusy</code> response code with text <em>The server cannot service this request right now. Try again later</em>.</p>
  
  <p>This may have to do with <a href="http://blogs.msdn.com/b/mstehle/archive/2010/11/09/ews-best-practices-understand-throttling-policies.aspx" rel="nofollow">Exchange Server throttling policies</a>, but that link says:</p>
  
  <blockquote>The EWSFindCountLimit parameter specifies the maximum result size of FindItem or FindFolder calls that can exist in memory on the Client Access server at the same time for this user in this current process</blockquote>
  
  <p>so I expect to get the <code>ErrorExceededFindCountLimit</code> response code with text <em>You have exceeded the maximum number of objects that can be returned for the find operation. Use paging to reduce the result size and try your request again.</em></p>
  
  <p>The issues I have with these observations:</p>
  
  <p>1) I specify <code>MaxEntriesReturned</code> to prevent being overwhelmed with data, yet <strong>I get much more than I ask for</strong>. (Fine with ice cream, but not here).</p>
  
  <p>2) If I do indeed bump into a throttling policy I'd like a decent <code>ErrorExceededFindCountLimit</code> <strong>response that tells me what is going on</strong>, so that my code can suggest corrective measures; <code>ErrorServerBusy</code> can mean many things.</p>
  
  <p>What can be done about both?</p>
  
  <p>This is all testing against Release to Manufacturing (RTM) <a href="https://technet.microsoft.com/en-us/library/hh135098%28v=exchg.150%29.aspx" rel="nofollow">version of Exchange Server 2013</a>:</p>
  
  <pre><code>&lt;ServerVersionInfo MajorVersion="15" MinorVersion="0" MajorBuildNumber="516" MinorBuildNumber="29" Version="Exchange2013"  .../&gt;
  </code></pre>