Ms office Office 365 outlook约会加载项未启动

Ms office Office 365 outlook约会加载项未启动,ms-office,office365,outlook-addin,office-addins,office-js,Ms Office,Office365,Outlook Addin,Office Addins,Office Js,尝试加载outlook约会时遇到问题。加载项。我们的命令显示在功能区ui中,加载项正在尝试启动,我们可以跟踪对wev应用程序的调用。我们没有收到任何错误,跟踪中有404或500个错误,服务会响应我们的第一个html页面,其中包含一个文本和一个按钮来启动我们的身份验证 但是在返回html之后,outlook只是停止加载项的微调器,并且什么也没有显示。有没有什么好的方法来调试它以了解发生了什么 html页面非常简单,只包含下面的代码 <head> <title>Off

尝试加载outlook约会时遇到问题。加载项。我们的命令显示在功能区ui中,加载项正在尝试启动,我们可以跟踪对wev应用程序的调用。我们没有收到任何错误,跟踪中有404或500个错误,服务会响应我们的第一个html页面,其中包含一个文本和一个按钮来启动我们的身份验证

但是在返回html之后,outlook只是停止加载项的微调器,并且什么也没有显示。有没有什么好的方法来调试它以了解发生了什么

html页面非常简单,只包含下面的代码

<head>
    <title>Office-bokning</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="https://appsforoffice.microsoft.com/fabric/2.2.0/fabric.min.css">
    <link rel="stylesheet" href="https://appsforoffice.microsoft.com/fabric/2.2.0/fabric.components.min.css">
    <script src="https://appsforoffice.microsoft.com/lib/1/hosted/Office.js" type="text/javascript"></script>
    <!--[authentication-popup-script]-->
    <script>
        startCheck = function () {
            var checkCode = setInterval(function () {

                localStorage.setItem('dummy', "dummy");
                localStorage.removeItem('dummy');
                var code = localStorage.getItem('code');
                var externalProviderUserId = localStorage.getItem('externalProviderUserId');

                function readCookie(name) {
                    var nameEQ = name + "=";
                    var ca = document.cookie.split(';');
                    for (var i = 0; i < ca.length; i++) {
                        var c = ca[i];
                        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
                        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
                    }
                    return null;
                }

                var fallbackCode;
                var fallbackExternalProviderUserId;

                if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
                    fallbackCode = readCookie('NAME_OF_COOKIE');
                    fallbackExternalProviderUserId = readCookie('externalProviderUserId');
                }
                console.log("code " + code);
                if (code || fallbackCode) {
                    clearInterval(checkCode);

                    var http = new XMLHttpRequest();
                    var url = [URL]
                    http.open("POST", url, true);

                    //Send the proper header information along with the request
                    http.setRequestHeader("Content-type", "text/plain");
                    //var that = this;
                    http.onreadystatechange = function () {
                        if (http.readyState == 4 && http.status == 200) {
                            localStorage.removeItem('code');
                            localStorage.removeItem('externalProviderUserId');
                            window.location.href = "[URL]";
                            //location.reload();
                        }
                    }
                    http.send(params);
                }
            }, 1000);
        }

        startCheck();
    </script>
</head>
    <body class="container-fluid" style="padding-left: 0px; padding-right: 0px; height: 100%">
        <p>
            Some text describing the addin...
        </p>
        <!--[popup-button]-->
        <script>
            Office.initialize = function (reason) {
                console.log("authorize office init" + reason);
                var butan = document.getElementById('loginButton');
                if (butan)
                    butan.style.display = 'block';
            }

            function commandFunction(event) {
                event.completed();
            }
        </script>
    </body>

办公室博克宁
startCheck=函数(){
var checkCode=setInterval(函数(){
setItem('dummy','dummy');
localStorage.removietem('dummy');
var code=localStorage.getItem('code');
var externalProviderUserId=localStorage.getItem('externalProviderUserId');
函数readCookie(名称){
变量nameEQ=name+“=”;
var ca=document.cookie.split(“;”);
对于(变量i=0;i
Office.initialize=函数(原因){
console.log(“authorize office init”+原因);
var butan=document.getElementById('loginButton');
if(丁烷)
butan.style.display='block';
}
函数命令函数(事件){
事件。已完成();
}

粘贴的HTML没有对Office.js的引用:
粘贴的HTML没有对Office.js的引用:
TL;DR:看来你想弹出一个页面供auth使用。使用displayDialogAsync API完成此操作。

看看你的代码,我看不出有什么问题。此外,根据您拥有的代码,您描述的行为实际上是正确的

我看到您有一个名为“commandFunction”的函数,它接受一个“event”参数。我猜您的清单中有一个调用commandFunction的ExecuteFunction

因此,当用户在约会窗口的功能区ui中单击外接程序的按钮时,Outlook将加载html网页,调用“Office.initialize”,在约会窗口的“主题”字段上方显示应用程序的默认微调器,然后调用“commandFunction”。此函数中唯一的代码是“event.completed”,因此Outlook调用该代码,这基本上结束了应用程序的执行,此时Outlook将删除默认微调器以表示完成。这正是你正在经历的

在调用“event.completed”之前,必须运行“commandFunction”中的任何相关代码。例如,您可以添加代码,在调用“event.completed”之前将通知消息/信息栏添加到约会中。示例代码如下:

function commandFunction(event)
{
    Office.context.mailbox.item.notificationMessages.addAsync
    (
        "some_unique_id_such_as_a_guid",
        {
            type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage,
            persistent: false,
            message: "hello world",
            icon: "default_icon"
        },
        function (asyncResult)
        {
            // check asyncResult.status
            // do something
            event.completed(true);
        }
    );
}
function commandFunction(event)
{
    Office.context.ui.displayDialogAsync
    (
        "https://ur/to/auth/page",
        {
            width: 50,
            height: 45,
            requireHTTPS: true
        },
        function (asyncResult)
        {
            // check asyncResult.status
            // do something
            event.completed(true);
        }
    );
}
在继续执行应用程序之前,您似乎希望打开一个html窗口供用户进行身份验证。在这种情况下,您应该通过在“event.completed”之前的“commandFunction”中调用“displayDialogAsync”API来使用它。这将打开一个指向身份验证页面URL的IE窗口。示例代码如下:

function commandFunction(event)
{
    Office.context.mailbox.item.notificationMessages.addAsync
    (
        "some_unique_id_such_as_a_guid",
        {
            type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage,
            persistent: false,
            message: "hello world",
            icon: "default_icon"
        },
        function (asyncResult)
        {
            // check asyncResult.status
            // do something
            event.completed(true);
        }
    );
}
function commandFunction(event)
{
    Office.context.ui.displayDialogAsync
    (
        "https://ur/to/auth/page",
        {
            width: 50,
            height: 45,
            requireHTTPS: true
        },
        function (asyncResult)
        {
            // check asyncResult.status
            // do something
            event.completed(true);
        }
    );
}
displayDialogAsync API的文档位于:

要进行调试,请打开IE,转到“Internet选项”->“常规选项卡”->单击“设置”按钮打开“网站数据设置”窗口。在“临时Internet文件”选项卡的“检查存储页面的更新版本”下,选择“每次访问该网页”。单击“确定”

现在转到“高级”选项卡->“设置”部分并取消选中以下选项:

  • 禁用脚本调试(Internet Explorer)
  • 禁用脚本调试(其他)
然后检查以下各项:

  • 显示关于每个脚本错误的通知
然后在“commandFunction”中添加“debugger;”作为第一行:

这将提示您在运行应用程序时调试代码。您可以在VisualStudio中调试并转到