You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Outlook加载项Manifest文件调用JavaScript函数失败求助

问题排查与修复方案

1. 函数未接收event参数

你的showAlert1函数直接调用event.completed(),但未将event作为参数传入,导致event变量未定义,无法结束请求,进而一直显示“正在处理请求”。

修改Functions.js:

function showAlert1(event) {
    // 后续逻辑
    event.completed();
}

2. 禁止使用原生alert

Outlook加载项的无UI执行函数(ExecuteFunction类型)运行在后台上下文,没有浏览器DOM环境,原生alert无法正常触发。需改用Office.js提供的通知API:

修改后的Functions.js:

function showAlert1(event) {
    Office.context.mailbox.item.notificationMessages.addAsync(
        "alertNotification",
        {
            type: "informationalMessage",
            message: "This is an alert box!",
            icon: "icon16",
            persistent: false
        },
        function(result) {
            event.completed();
        }
    );
}

3. 确保Functions.html加载Office.js

Functions.html中必须先加载Office.js,否则无法调用Office相关API。在引入Functions.js前添加Office.js引用:

修改Functions.html:

<script src="https://appsforoffice.microsoft.com/lib/1/hosted/office.js" type="text/javascript"></script>
<script src="Functions.js" type="text/javascript"></script>

4. 验证函数文件路径

确认https://localhost:3000/Functions.html可正常访问,同时检查浏览器控制台是否有Functions.js的404加载错误(若文件在同一目录,当前引用路径没问题,但需确认本地服务的文件映射正确)。

内容的提问来源于stack exchange,提问作者Termite_nest

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.16 02:48:15