我知道我可以通过Office.context.mailbox.item.attachments
对于每个附件,我都可以访问其附件,例如name
但是我可以实际访问其内容并将其发送到外部服务器以显示它吗?例如,我想将pdf附件发送到服务器,然后在服务器上显示该pdf文件的内容。
答案 0 :(得分:2)
事实证明,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 : []
};