Reputation: 31
Trying to get the attachment contents (files) against mail item in outlook web add-in (Office 365) using the EWS request as instructed in the link below: https://learn.microsoft.com/en-us/exchange/client-developer/exchange-web-services/how-to-get-attachments-by-using-ews-in-exchange
Successfully got the attachment ids, but while passing those attachment ids to the GetAttachment request envelope, it fails and returns the following response: {"value":null,"status":"failed","error":{"name":"GenericResponseError","message":"The requested web method is unavailable to this caller or application.","code":9020}}
function getAttachmentsByAttachmentId(attachmentId){
var requestEnvelopStr = '<?xml version="1.0" encoding="utf-8" ?>';
requestEnvelopStr += '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">';
requestEnvelopStr += '<soap:Header>';
requestEnvelopStr += '<t:RequestServerVersion Version="Exchange2010" />';
requestEnvelopStr += '</soap:Header>';
requestEnvelopStr += '<soap:Body>';
requestEnvelopStr += '<m:GetAttachment>';
requestEnvelopStr += '<m:AttachmentIds>';
requestEnvelopStr += '<t:AttachmentId Id="' + attachmentId+'" />';
requestEnvelopStr += '</m:AttachmentIds>';
requestEnvelopStr += '</m:GetAttachment>';
requestEnvelopStr += '</soap:Body>';
requestEnvelopStr += '</soap:Envelope>';
console.log("Before Calling EWS...");
//Calling EWS
Office.context.mailbox.makeEwsRequestAsync(requestEnvelopStr, attachmentsCallBack);
}
function attachmentsCallBack(asyncResultAttachments) {
console.log("asyncResultAttachments.value = " + JSON.stringify(asyncResultAttachments));
}
Upvotes: 3
Views: 1056
Reputation:
This is by design. Getting attachment contents is not supported by addins through EWS. A supported list of APIs can be found here. A potential solution would be to use one of our preview API's documented here. Keep in mind that since the API is in preview it may be prone to bugs until it's released as part of a requirement set. Another solution could be to have your backend make the call to retrieve the attachment content.
Upvotes: 1