title: How can I use ExchangeService to access a shared mailbox (Outlook 2013)
body: <p>I am trying to access a second mailbox in outlook using an ExchangeService. but when I run the application it grabs my main email. Its worth noting that I use windows authentication here, and that I need to for this to work.</p>
  
  <pre><code>var useExchangeServer = new UseExchangeServer("SECONDEMAIL@mycompany.com");
  var messages = useExchangeServer.LoadMessages(1);
  
  foreach (var message in messages){ //At this point message has the wrong email...
  ...
  }
  </code></pre>
  
  <p>here is my "UseExchangeServer" class</p>
  
  <pre><code>public UseExchangeServer(string mailBox)
      {
          _service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
          _service.UseDefaultCredentials = true;
          _service.AutodiscoverUrl(mailBox);
      }
  
  public FindItemsResults&lt;Item&gt; GetLastItems(int numberOfItems)
      {
          return _service.FindItems(WellKnownFolderName.Inbox, new ItemView(numberOfItems));
      }
  
  public IEnumerable&lt;EmailMessage&gt; LoadMessages(int numberOfMessages)
      {
          var findResults = GetLastItems(numberOfMessages);
  
          foreach (var item in findResults.Items)
          {
              var message = EmailMessage.Bind(_service, item.Id, new PropertySet(BasePropertySet.IdOnly, ItemSchema.Attachments));
              message.Load();
              yield return message;
          }
      }
  </code></pre>