title: Getting attachments from Exchange Managed API using ASP.NET Core
body: <p>I am in the process of building an Outlook Add-In that authenticates to an external API that is also in my possession. For one of my functions, I am sending a list of attachment IDs from the add-in to the API. I can then use these IDs to get the corresponding attachments from Microsoft's Exchange Managed API. The issue is that because I'm using .NET Core, the recommended libraries are lacking the necessary functionality needed to access the attachments.</p>
  
  <p>Here is some code that I am trying to use to access the attachments from the main <code>Microsoft.Exchange.WebServices</code> library:</p>
  
  <pre><code>ServiceResponseCollection&lt;GetAttachmentResponse&gt; getAttachmentsResponse = service.GetAttachments(attachmentInfo.attachmentIds.ToArray(), null, new PropertySet(BasePropertySet.FirstClassProperties, ItemSchema.MimeContent));
  
  if (getAttachmentsResponse.OverallResult == ServiceResult.Success)
  {
      foreach (var attachmentResponse in getAttachmentsResponse)
      {
          // removed logic for simplicity
      }
  }
  </code></pre>
  
  <p>The issue is that the first line of code throws an error unless I append <code>.Result</code> on the end of it. This is some flaw in the .NET Core version of the library. When I go with it, the task never leaves the status of <code>Awaiting Action</code> or something similar. </p>
  
  <p>Another library that is supposedly adjusted for .NET Core is <code>Microsoft.Exchange.WebServices.NETStandard</code>.</p>
  
  <p>Here is some code I found that is suppose to work:</p>
  
  <pre><code>var getAttachmentsResponse = service.GetAttachments(attachmentInfo.attachmentIds.ToArray(), null, new PropertySet(BasePropertySet.FirstClassProperties, ItemSchema.MimeContent));
  
  foreach (var attachmentResponse in getAttachmentsResponse)
  {
      // removed logic for simplicity
  }
  </code></pre>
  
  <p>With this sample, the object models are different and there is not even an <code>Overall Result</code> on the response. Not to mention, the call fails immediately with errors about there being a duplicate key. I may remember reading somewhere that this method only accepts username/password credentials.</p>
  
  <p>Does anyone have any other solutions that could help me receive attachments from Outlook emails from my API? Am I missing something painfully obvious?</p>