title: How to retrieve ItemAttachment bytes
body: <p>I want to download the bytes of an attachment to an email that is itself an email using Microsoft Graph. </p>
  
  <p>My only option at the moment appears to be to use the Get <code>ItemAttachment</code> method on the API that looks like this:</p>
  
  <pre><code>https://graph.microsoft.com/v1.0/users/myAccount/messages/{messageId}/attac
  hments/{attachmentId}?$expand=microsoft.graph.itemattachment/item
  </code></pre>
  
  <p>and the returned JSON has an <code>item</code> node with this value:</p>
  
  <pre class="lang-json prettyprint-override"><code>{
    "@odata.type": "#microsoft.graph.message",
    "id": "",
    "createdDateTime": "2018-01-18T01:51:02Z",
    "lastModifiedDateTime": "2018-01-18T01:50:36Z",
    "receivedDateTime": "2018-01-18T00:21:35Z",
    "sentDateTime": "2018-01-18T00:21:48Z",
    "hasAttachments": true,
    "internetMessageId":
      "&lt;2097905212.0.1516234908909.JavaMail.root@dszsarapps01r&gt;",
    "subject": "blah",
    "importance": "normal",
    "conversationId":
      "AAQkADQ3YjdiNWUxLTBmYWQtNDMwYy04YzDFjNgAQAFM3Iqwf0gRHqfUyw2AniAQ=",
    "isReadReceiptRequested": false,
    "isRead": true,
    "isDraft": false,
    "webLink":
      "https://outlook.office365.com/owa/?ItemID=AAMkADQ3YjdiNWUxLTOWQ4NDFjNgAAAA%3D%3D&amp;exvsurl=1&amp;viewmodel=ReadMessageItem",
    "body": {
      "contentType": "text",
      "content": "some content"
    },
    "sender": {
      "emailAddress": {
        "name": "me@somewhere",
        "address": "me@somewhere"
      }
    },
    "from": {
      "emailAddress": {
        "name": "boo@there",
        "address": "boo@there"
      }
    },
    "toRecipients": [
      {
        "emailAddress": {
          "name": "him@where",
          "address": "him@where"
        }
      }
    ]
  }
  </code></pre>
  
  <p>Note that the presence of attachments is indicated by the <code>hasAttachments</code> field but the attachments are not visible in the JSON.</p>
  
  <p>I suspect that nested attachments/emails (possibly to many levels) are not supported by Graph API but even if it were it would be risky and time-consuming trying to reconstruct the original bytes of the <code>.eml</code> attachment from JSON.</p>
  
  <p>I would rather treat the <code>ItemAttachment</code> as a <code>FileAttachment</code> and download its bytes. Does anyone know how to do this?</p>