我正在添加一个“添加附件”命令作为 Office Outlook 加载项的一部分。
我想找到一种从具有授权的 URL 添加文件的方法。
我想用 ajax 下载它,然后从 blob 中保存它,但看起来该命令不支持它。我的代码测试它失败了:
const text = 'attachment content';
const blob = new Blob([text], {type: 'text/plain'});
const attachmentURI = window.URL.createObjectURL(blob);
Office.context.mailbox.item.addFileAttachmentAsync(
attachmentURI,
'file.txt',
{ asyncContext: null },
function (asyncResult) {
if(asyncResult.status == Office.AsyncResultStatus.Failed){
console.log('error adding attachment: ' + asyncResult.error.message);
}
else {
const attachmentID = asyncResult.value;
console.log('added attachment: ' + attachmentID);
}
}
);
有关从具有权限的 URL 保存附件的任何建议?
功能文档: https ://dev.office.com/docs/add-ins/outlook/add-and-remove-attachments-to-an-item-in-a-compose-form