2

尝试按照以下链接中的说明使用 EWS 请求针对 Outlook Web 加载项 (Office 365) 中的邮件项获取附件内容(文件): https ://docs.microsoft.com/en-us/exchange/client -developer/exchange-web-services/how-to-get-attachments-by-using-ews-in-exchange

成功获取附件 ID,但在将这些附件 ID 传递到 GetAttachment 请求信封时,它失败并返回以下响应:{"value":null,"status":"failed","error":{"name": "GenericResponseError","message":"请求的 web 方法对这个调用者或应用程序不可用。 ","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));
}
4

1 回答 1

1

这是设计使然。插件不支持通过 EWS 获取附件内容。可在此处找到受支持的 API 列表。一个潜在的解决方案是使用我们在此处记录的预览 API 之一。请记住,由于 API 处于预览状态,因此在作为需求集的一部分发布之前,它可能容易出现错误。另一种解决方案可能是让您的后端调用以检索附件内容。

于 2019-09-11T00:08:33.400 回答