title: Get multiple mailboxes from a master mailbox using EWS
body: <p>We would like to be able to obtain unread mails from all the mailboxes contained in our exchange server. From there, we will process them in our application and then delete them. The number of unread mails will always be in small proportion. </p>
  
  <p>Our first idea was to create a master mailbox, give him full access (with EPS) to other mailboxes and obtain the unread mails with EWS. We tried with this :</p>
  
  <pre><code>        //Define the service 
          ExchangeService service = new ExchangeService(SERVICE_VERSION);
          service.Url = new Uri(SERVICE_URL);
          service.Credentials = new WebCredentials("MyAdmin", "MyPassword");
  
          //define our search
          FolderView viewFolders = new FolderView(int.MaxValue) { Traversal = FolderTraversal.Deep, PropertySet = new PropertySet(BasePropertySet.IdOnly) };
          ItemView viewEmails = new ItemView(int.MaxValue) { PropertySet = new PropertySet(BasePropertySet.IdOnly) };
          SearchFilter unreadFilter = new SearchFilter.SearchFilterCollection(LogicalOperator.And, new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false));
  
          //search all items in Inbox and subfolders
          FindItemsResults&lt;Item&gt; findResults = service.FindItems(WellKnownFolderName.Root, unreadFilter, viewEmails);
  
          //bind the result
          ServiceResponseCollection&lt;GetItemResponse&gt; responseList =
                 service.BindToItems(findResults.Select(item =&gt; item.Id), new PropertySet(BasePropertySet.FirstClassProperties,EmailMessageSchema.ReceivedBy, EmailMessageSchema.From, EmailMessageSchema.Subject, EmailMessageSchema.Attachments));
  </code></pre>
  
  <p>However this will only get the unread mails from the MyAdmin mailbox. With further investigation, we found this way to obtain unread mail from another specific mailbox :</p>
  
  <pre><code>        //Define the service 
          ExchangeService service = new ExchangeService(SERVICE_VERSION);
          service.Url = new Uri(SERVICE_URL);
          service.Credentials = new WebCredentials("MyAdmin", "MyPassword");
  
          //define our search
          FolderView viewFolders = new FolderView(int.MaxValue) { Traversal = FolderTraversal.Deep, PropertySet = new PropertySet(BasePropertySet.IdOnly) };
          ItemView viewEmails = new ItemView(int.MaxValue) { PropertySet = new PropertySet(BasePropertySet.IdOnly) };
          SearchFilter unreadFilter = new SearchFilter.SearchFilterCollection(LogicalOperator.And, new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false));
  
          //define the user mailbox
          var userMailbox = new Mailbox("MyUser@Domain.com");
          var folderId = new FolderId(WellKnownFolderName.Inbox, userMailbox);
  
          //search all items in Inbox
          var userItems = service.FindItems(folderId, unreadFilter, viewEmails);
  </code></pre>
  
  <p>The problem with this solution is for 3000 mailboxes, we must then query 3000 times the EWS to obtain the unread mails from every mailbox (Knowing that many won't have unread mails).</p>
  
  <p>Is there a way to obtain, in a single call, all the unread mails from every mailboxes of the exchange server? We are using exchange 2013 with the latest EWS.</p>
  
  <p>Thanks in advance</p>