0

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 Microsoft's documentation i wrote this code :

   /// <reference path="../App.js" />
    // 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 < item.attachments.length; i++) 
                 {
                     serviceRequest.attachmentIDs.push(item.attachments[i].id);


                }
                makeServiceRequest();


            }
        }

But when I arrive at the implementation fo the function makeServiceRequest() I don't know what i need to do. Microsoft's documentation](https://dev.office.com/docs/add-ins/outlook/get-attachments-of-an-outlook-item) gives me C# codes but I don't understand. I've only .js files ...

Philip Rueker
  • 948
  • 5
  • 15

1 Answers1

1

The only way to access attachments, is to make an EWS or REST call from your backend service. So you must take the callback token, ews url and attachment id and pass them back to your backend, so you can make the call to get attachment from there. That's why you're seeing C# code.

AndrewS
  • 369
  • 1
  • 5