访问 Outlook Web 加载项中的附件 [英] Access to the attachment in Outlook web add-in

查看:56
本文介绍了访问 Outlook Web 加载项中的附件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

Also for each of the attachment I get to access to its members like name

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

But can I actually access to its content and send it to a external server to show it? For example I want to send a pdf attachment to a server, and on the server I want to show the content of that pdf file.

推荐答案

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

Turns out that An Outlook Add-in cannot pass the attachments of a selected item directly to the remote service that runs on your server. Instead, the add-in can use the attachments API to send information about the attachments to the remote service. The service can then contact the Exchange server directly to retrieve the attachments.

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    : []
    };

通过检索附件EWS 托管 API

这篇关于访问 Outlook Web 加载项中的附件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆