Office.context.ui 使用 Exchange 2013 帐户取消对 Outlook Web App 的保护

Office.context.ui undefiend for Outlook Web App with Exchange 2013 account

我需要 Exchange 2013 帐户支持的 Outlook Web 插件。因此,在为 Outlook Web 应用程序添加清单文件后加载项加载得很好。

我正在使用 Dialog API 弹出窗口实现 登录 功能。因此,当客户点击登录按钮时,它会显示 Cannot read property 'displayDialogAsync' of undefined

在调试时我开始知道 Office.context 不包含 ui 属性 .

任何人都可以解决我哪里出错的问题吗?ui或者此对话框 API 是否支持包含交换帐户的 Outlook Web 应用程序。

My add-in is working nicely for Outlook Desktop, Outlook Web and mobile as well

if (window.hasOwnProperty('Office')) {
      Office.context.ui.displayDialogAsync(
        `${window.location.origin}/#/signin/` + Office.context.mailbox.userProfile.emailAddress,
        {
          height: 60,
          width: 20
        },
        (result) => {
          const dialog = result.value;
          dialog.addEventHandler(
            Office.EventType.DialogMessageReceived,
            (e: { type: string, message: string }) => {
              if (e.message === 'true') {
                this.oAuthService.initImplicitFlow();
              }
              dialog.close();
            });
        }
      );
      }

您需要检查要求集。

需求集是 API 成员的命名组。 Office Add-ins 使用清单中指定的要求集或使用运行时检查来确定 Office 主机是否支持 add-in 需要的 API。有关详细信息,请参阅 Office 版本和要求集。 displayDialogAsync 方法在 Word、Excel 或 PowerPoint add-in 的 DialogApi 要求集以及 Outlook 的邮箱要求集 1.4 中可用。

有关对话框API的要求的详细信息,请参阅Dialog API requirement sets

错误处理

您的回调需要检查 result.error.coderesult.error.message。一旦知道错误是什么,就可以开始进行故障排除。例如。

var dialog;
Office.context.ui.displayDialogAsync('https://myDomain/myDialog.html',
   function (asyncResult) {
       if (asyncResult.status === Office.AsyncResultStatus.Failed) {
            showNotification(asyncResult.error.code = ": " + asyncResult.error.message);
       } else {
            dialog = asyncResult.value;
            dialog.addEventHandler(Office.EventType.DialogMessageReceived, processMessage);
      }
});