简体   繁体   English

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

[英]outlook 365 add-in: Office.context is always empty

I work on a simple add-in for outlook 365, but it looks like I'm missing some simple point since office.context variable is always empty for me, for example even base code sample: 我正在为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.
    });
}

What can I miss? 我想念什么? Adds-in permission is highest -- ReadWriteMailbox 加载项权限最高-ReadWriteMailbox

Try to take some work example , for example: https://github.com/OfficeDev/Outlook-Add-in-Commands-Translator You need parts of home.html and home.js. 尝试以一些工作示例为例,例如: https : //github.com/OfficeDev/Outlook-Add-in-Commands-Translator您需要home.html和home.js的一部分。

I think this part of code need to work in your case: 我认为这部分代码需要在您的情况下起作用:

(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 **


});
}; })();

I try it and it's work for me.. Good luck. 我尝试了,对我来说很奏效。祝您好运。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM