首页 > 解决方案 > 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}

标签: outlook-web-addinsoffice365-apps

解决方案


推荐阅读