outlook 365加载项:Office.context始终为空

时间:2017-06-26 11:49:06

标签: outlook office365 outlook-addin

我为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

1 个答案:

答案 0 :(得分:0)

尝试采取一些工作示例,例如: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 **


});
}; })();

我试一试,这对我有用.. 祝你好运。