[英]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.