title: Exchange Webservices Managed API - using ItemView.Offset for FindItems() hits performance of LoadPropertiesForItems method
body: <p>I'm doing a little research on possible application of EWS in our existing project which is written with heavy use of MAPI and I found out something disturbing about performance of LoadPropertiesForItems() method.</p>
  
  <p>Consider such scenario:</p>
  
  <ul>
  <li>we have 10000 (ten thousands) messages in Inbox folder</li>
  <li>we want to get approximately 30 properties of every message to see if they satisfy our conditions for further processing</li>
  <li>messages are retrieved from server in packs of 100 messages</li>
  </ul>
  
  <p>So, code looks like this:</p>
  
  <pre><code>        ItemView itemsView = new ItemView(100);
  
          PropertySet properties = new PropertySet();
          properties.Add(EmailMessageSchema.From);
          /*
          add all necessary properties...
          */
          properties.Add(EmailMessageSchema.Sensitivity);
  
          FindItemsResults&lt;Item&gt; findResults;
          List&lt;EmailMessage&gt; list = new List&lt;EmailMessage&gt;();
  
          do
          {
              findResults = folder.FindItems(itemsView);                
              _service.LoadPropertiesForItems(findResults, properties);
  
              foreach (Item it in findResults)
              {
                  ... do something with every items
              }
  
              if (findResults.NextPageOffset.HasValue)
              {
                  itemsView.Offset = findResults.NextPageOffset.Value;
              }
  
          }while(findResults.MoreAvailable);
  </code></pre>
  
  <p>And the problem is that every increment of itemsView.Offset property makes LoadPropertiesForItems method longer to execute. For first couple of iterations it is not very noticeable but around 30th time loop makes that call time increases from under 1 second to 8 or more seconds. And memory allocation hits physical limits causing out of memory exception.</p>
  
  <p>I'm pretty sure that my problems are "offset related" because I changed a code a little to that:</p>
  
  <pre><code>        itemsView = new ItemView(100, offset, OffsetBasePoint.Beginning);
          ...rest of loop
          if (findResults.NextPageOffset.HasValue)
          {
              offset = findResults.NextPageOffset.Value;
          }
  </code></pre>
  
  <p>and I manipulated offset variable (declared outside of loop) in that way that I set its value on 4500 at start and than in debug mode after first iteration I changed its value to 100. And according to my suspicions first call of LoadPropertiesForItems took veeeery long to execute and second call (with offset = 100) was very quick.</p>
  
  <p>Can anyone confirm that and maybe propose some solution for that?</p>
  
  <p>Of course I can do my work without using an offset but why should I? :)</p>