title: Get attachment from Outlook Web App in JavaScript
body: <p>I try to retrieve attachments from a mail in an OWA (Outlook Web App). I use the tool "Napa" who allows me to create only .js, .css and . html files. So i need to use .js to retrieve the attachments. According to the  <a href="https://dev.office.com/docs/add-ins/outlook/get-attachments-of-an-outlook-item" rel="nofollow">Microsoft's documentation</a> i wrote this code :</p>
  
  <pre><code>   /// &lt;reference path="../App.js" /&gt;
      // global app
      var serviceRequest;
      var xhr;
  
      (function () {
          'use strict';
  
          // The Office initialize function must be run each time a new page is loaded
          Office.initialize = function (reason) {
              $(document).ready(function () {
                  app.initialize();
  
  
                if (Office.context.mailbox.item.attachments.length !== 0) 
                {
  
                      serviceRequest = new Object();
                      serviceRequest.attachmentToken = "";
                      serviceRequest.ewsUrl = Office.context.mailbox.ewsUrl;
  
                      serviceRequest.attachmentIDs = new Array();
                      Office.context.mailbox.getCallbackTokenAsync(getAttachment);
  
                 }
  
  
              });
          };
  
  
  
  
  
  
          function getAttachment(asyncResult)
          {
              if(asyncResult.status==="succeeded")
              {
                  serviceRequest.attachmentToken = asyncResult.value;
  
                   var item = Office.context.mailbox.item;
                   for (var i = 0; i &lt; item.attachments.length; i++) 
                   {
                       serviceRequest.attachmentIDs.push(item.attachments[i].id);
  
  
                  }
                  makeServiceRequest();
  
  
              }
          }
  </code></pre>
  
  <p>But when I arrive at the implementation fo the function <em>makeServiceRequest()</em> I don't know what i need to do. Microsoft's documentation](<a href="https://dev.office.com/docs/add-ins/outlook/get-attachments-of-an-outlook-item" rel="nofollow">https://dev.office.com/docs/add-ins/outlook/get-attachments-of-an-outlook-item</a>) gives me C# codes but I don't understand. I've only .js files ...</p>