[英]outlook 365 add-in: Office.context is always empty
我正在为Outlook 365开发一个简单的加载项,但由于我对office.context变量始终为空,例如,即使是基本代码示例,也似乎缺少了一些简单的要点:
// The initialize function is required for all apps.
Office.initialize = function () {
// Checks for the DOM to load using the jQuery ready function.
$(document).ready(function () {
// After the DOM is loaded, app-specific code can run.
var item = Office.context.mailbox.item;
var subject = item.subject;
// Continue with processing the subject of the current item,
// which can be a message or appointment.
});
}
我想念什么? 加载项权限最高-ReadWriteMailbox
尝试以一些工作示例为例,例如: https : //github.com/OfficeDev/Outlook-Add-in-Commands-Translator您需要home.html和home.js的一部分。
我认为这部分代码需要在您的情况下起作用:
(function () {
'use strict';
// The initialize function must be run each time a new page is loaded
Office.initialize = function (reason) {
$(document).ready(function () {
** now try to get the item **
});
}; })();
我尝试了,对我来说很奏效。祝您好运。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.