简体   繁体   中英

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:

// 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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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