访问 Outlook Web 插件中的附件

Access to the attachment in Outlook web add-in

我知道我可以通过 Office.context.mailbox.item.attachments

访问附件

此外,对于每个附件,我都可以访问其成员,例如 name

但我真的可以访问它的内容并将其发送到外部服务器来显示吗?例如我想发送一个pdf附件到服务器,我想在服务器上显示那个pdf文件的内容。

事实证明,Outlook 加载项无法将所选项目的附件直接传递到在您的服务器上运行的远程服务。相反,加载项可以使用附件 API 将有关附件的信息发送到远程服务。该服务然后可以直接联系 Exchange 服务器以检索附件。

function getAttachmentToken() {
  if (serviceRequest.attachmentToken == "") {
      Office.context.mailbox.getCallbackTokenAsync(attachmentTokenCallback);
  }
}

function attachmentTokenCallback(asyncResult, userContext) {
  if (asyncResult.status === "succeeded") {
      // Cache the result from the server.
      serviceRequest.attachmentToken = asyncResult.value;
      serviceRequest.state = 3;
      testAttachments();
  } else {
      showToast("Error", "Could not get callback token: " + asyncResult.error.message);
  }
}

// Initialize a context object for the add-in.
//   Set the fields that are used on the request
//   object to default values.
var serviceRequest = {
    attachmentToken: '',
    ewsUrl         : Office.context.mailbox.ewsUrl,
    attachments    : []
    };

Retrieve attachment via EWS managed API