outlook-web-addins - Office.context.mailbox.item.addFileAttachmentAsync 通常需要很长时间才能附加并且出现内部格式错误
问题描述
尝试通过从 Office 365 Outlook 加载项(网络上)调用 Office.context.mailbox.item.addFileAttachmentAsync 来附加文件时发生错误。
在加载 Outlook 网站后,这种情况经常发生。加载后一段时间后可能不会出现。它出现在 IE、Chrome(在 Windows10、Mac 上)和 Safari(在 Mac 上)。桌面版没有问题。
这种情况以前没有发生过,但最近发生了。在过去的几个月里,Outlook 加载项没有任何变化。
我创建并测试了以下简单程序。在这个程序中也会出现同样的错误。
Office.initialize = function (reason) {
$(document).ready(function () {
$("#send-btn").click(function () {
try {
var url = "https://www.cloudstoragelight.com/proaxiastorage/f/Demo/TestData.xlsx";
var attachemrtFilename = "TestData.xlsx";
debugger;
Office.context.mailbox.item.addFileAttachmentAsync(
url,
attachemrtFilename,
{ asyncContext: null },
function (asyncResult) {
if (asyncResult.status == Office.AsyncResultStatus.Failed) {
if (asyncResult.error && asyncResult.error.message) {
console.log("Error(" + asyncResult.error.message + ")");
} else {
console.log("Error");
}
}
else {
console.log("SUCCESS");
}
});
} catch (e) {
if (e.message) {
console.log("Error(" + e.message + ")");
} else {
console.log("Error");
}
}
});
});
};
有什么解决方法吗?
[附加信息] 我尝试使用 Outlook-web-16.01.debug.js 进行调试。
发生错误时查看堆栈的内容,有一个_checkMethodTimeout函数。该函数的超时判断已经变为真,并且已经调用了Callback。
在这种情况下,Microsoft.Office.Common.ClientEndPoint.invoke 函数在 postMessage 中发送以下消息。
{“_messageType”:0,“_actionName”:“ExecuteMethod”,“_conversationId”:“7cc28a93_6a3c12a5_1581127643048”,“_correlationId”:5,“_origin”:“https:// localhost:44313 / MessageRead.html?et =”, “_data”:{“ApiParams”:{“uri”:“ https://www.cloudstoragelight.com/proaxiastorage/f/Demo/TestData.xlsx ”,“名称”:“TestData.xlsx”,“isInline”:假,“__ timeout __”:600000},“MethodData”:{“ControlId”:“963d4dfe-eaad-8e5b-6fa5-3eaac31b660d”,“DispatchId”:16}},“_ actionType”:0,“_ serializerVersion “:1}
解决方案
推荐阅读
- javascript - 我的 Javascript 函数是否在 Angular HTML 模板中运行?
- powerbi - 如何按季度计算视觉对象的唯一值
- python - 使用 pyinstaller 创建的 .exe 不工作,但在 IDE 中运行的 .py 文件工作
- c# - 统一3d。使用视频播放器渲染纹理
- lua - 解析lua中的符号链接
- apache-spark - [Ab] 使用 Spark 作为故障转移平台运行 Java 应用实例
- swift - 尝试在 iPhone 相册中保存清晰的二维码图片
- angular - 为什么 Angular CLI 在 HTTPS 上打开我的网站
- react-native - 如何在 React Native 中制作类似 Instagram 的响应式设计?
- javascript - 广告移除后修补 DOM - chrome 扩展