Access to the attachment in Outlook web add-in

◇◆丶佛笑我妖孽 提交于 2019-12-23 03:24:17

问题


I know I can access to the attachments via Office.context.mailbox.item.attachments

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

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.


回答1:


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

Retrieve attachment via EWS managed API



来源:https://stackoverflow.com/questions/51762073/access-to-the-attachment-in-outlook-web-add-in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!