Office.context.ui.displayDialogAsync引发5001内部错误 [英] Office.context.ui.displayDialogAsync throws 5001 Internal Error
问题描述
我正在使用Visual Studio项目模板创建一个新的Outlook Mail加载项,在这里我得到一个显示当前所选电子邮件属性的示例.
I'm creating a new Outlook Mail add-in using the Visual Studio project template, where I get a sample displaying properties of the currently selected email.
我添加了带有点击事件处理程序的按钮,以使用以下代码打开对话框:
I've added a button with a click event handler to open a dialog using this code:
$('#clickMeButton').click(function () {
Office.context.ui.displayDialogAsync('https://localhost/OutlookAddinTest/MessageDialog.html', {
height: 40,
width: 40,
requireHTTPS: true
}, function (result) {
_dlg = result.value;
_dlg.addEventHandler(Microsoft.Office.WebExtension.EventType.DialogMessageReceived, dialogMessageReceived);
});
});
我正在使用Chrome中的Outlook Web客户端进行调试:
I'm debugging this using the Outlook web client in Chrome:
我不知道它是否与此错误有关,但是在加载网站之后,在单击clickMeButton之前,我可以看到以下错误:
I don't know if it's relevant for this error, but I can see the following error after the web site is loaded, before I click the clickMeButton:
osfruntime.js:13 Error while parsing the 'sandbox' attribute: 'ms-allow-popups' is an invalid sandbox flag.OSF.OsfControl._createIframeAndActivateOsfControl @ osfruntime.js:13
displayDialogAsync(...)
函数不是应该用于Outlook Mail加载项吗?这可能是一个问题,因为它会在Outlook主HTML页面的上下文中加载另一个HTML页面.但这在Outlook桌面客户端中都不起作用.
Isn't the displayDialogAsync(...)
function supposed to be used for Outlook Mail add-ins? It might be an issue because it would load another html page within the context of the main Outlook html page. But it doesn't either work in the Outlook desktop client.
推荐答案
- 错误
- 身份验证问题
错误osfruntime.js:13 Error while parsing the 'sandbox' attribute: ms-allow-popups
ms-allow-popups
是供应商前缀的CSS属性 a>.
的确,您可能知道外接程序位于沙盒iframe中.为了能够执行某些操作,此沙盒iframe具有一些额外的权限.例如,允许弹出窗口,但由于MS IE,Google Chrome,Firefox等在沙盒选项上未达成100%的同意,因此它们具有一些供应商"特定选项,而ms-allow-popups
是其中之一(对于MS IE).如果您使用devtools浏览iFrame,则会发现以下选项
sandbox="allow-scripts allow-forms allow-same-origin ms-allow-popups allow-popups".
Indeed, you may be aware that your add-in lives in a sandboxed iframe. To be able to do some things, this sandboxed iframe has some extra permissions. For example, popups are allowed but because MS IE, Google Chrome, Firefox etc. did not agree 100% on the sandbox options they have some 'vendor' specific options and ms-allow-popups
is one of them (for MS IE). If you browse the iFrame with the devtools you will find the following options
sandbox="allow-scripts allow-forms allow-same-origin ms-allow-popups allow-popups".
要总结此错误,您可以忽略它,因为它仅由Chrome引发,因为它不了解Microsoft供应商前缀.您的代码对此不承担任何责任.
To conclude on the error, you may ignore it because it is only raised by Chrome because it does not understand the Microsoft vendor prefix. Your code is not responsible for this.
现在有关dialogAPI.不幸的是,dialogAPI仅适用于Microsoft Outlook Desktop 2016的最新版本. (> = 16.0.6741.1000.).确保您的Outlook桌面是最新的. Web客户端(aka OWA)没有dialogAPI.您将无法在带有OWA的Chrome上看到任何对话框.
Now about the dialogAPI. Unfortunately, the dialogAPI is only available for Microsoft Outlook Desktop 2016 recent builds. (>= 16.0.6741.1000.). Make sure your Outlook Desktop is up-to-date. There is no dialogAPI for the web client (aka OWA). You will not be able to see any dialog on Chrome with OWA.
My solution implemented on Keluro is to use the dialogAPI when it is available with the following sample code (typescript).
hasDialogApi(): boolean {
var context: any = Office.context;
try {
return context.requirements.isSetSupported('DialogAPI', '1.1');
} catch (ex) {
return false;
}
}
如果dialogAPI不可用(旧的Outlook 2016,Outlook Web客户端),我们将退回到基于弹出窗口的身份验证流程.我们使用基于弹出窗口的登录机制结合SignalR/WebSockets来实现这样的流程.请参阅这篇文章和
if the dialogAPI is not available (old Outlook 2016, Outlook web clients) we fall back to an authentication flow based on popups. We use a sign in mechanism based on popups combined with SignalR/WebSockets to implement such a flow. See this post and this one to know more.
结论:在撰写本文时,带有dialogAPI的Outlook桌面构建并不十分普及,但是我们看到越来越多的用户使用它们. dialogAPI对于我们的外接程序开发人员至关重要,因为在没有OutlookAPI的Outlook Desktop中,大多数时候基于弹出框的身份验证方案将不起作用(禁用弹出框,禁止Web套接字等).目前,不带dialogAPI的Outlook Desktop代表了人们在Keluro上登录的最大部分.
Conclusion: Outlook desktop builds with dialogAPI are not very widespread at the time of the writing but we see more and more users with them. dialogAPI is crucial for us add-in developers because, with Outlook Desktop without dialogAPI, most of the time a popup based authentication scheme will not work (popup disabled, web socket forbidden etc.). For now, Outlook Desktop without dialogAPI represent the largest part of people sign-in on Keluro.
Note: for debugging the iFrame in Outlook desktop you may be interested in this.
这篇关于Office.context.ui.displayDialogAsync引发5001内部错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!