Outlook Web 加载项类别问题

问题描述 投票:0回答:1

我在设置展望类别时遇到问题。

我尝试通过使用 JS API 以及发送 EWS-Request 来设置邮件的类别。 这两种方法都适用于大多数邮件,但是,在某些邮件上,即使我收到来自 API 的成功消息,类别也未设置或设置后消失。

关于环境的一些背景信息: 测试环境版本:Outlook 365 16.0.14326.20702 32-Bit 混合交换版本:15.1(内部版本 2176.2)

主要逻辑如下所示:

let getMasterCategories = async function (masterCategoriesToAdd) {
  return new Promise((resolve, reject) => {
    Office.context.mailbox.masterCategories.getAsync(function (asyncResult) {
      if (asyncResult.status === Office.AsyncResultStatus.Failed) {
        console.log("Action failed with error: " + asyncResult.error.message);
        return reject(false);
      } else {
        const masterCategories = asyncResult.value;
        let categoryFound = false;
        console.log("Master categories:");
        masterCategories.forEach(function (item) {
          if (item.displayName == 'TestCat')
            categoryFound = true;
        });

        if (!categoryFound) {
          Office.context.mailbox.masterCategories.addAsync(masterCategoriesToAdd, function (asyncResult) {
            if (asyncResult.status === Office.AsyncResultStatus.Succeeded) {
              console.log("Successfully added categories to master list");
              return resolve(true);
            } else {
              console.log("masterCategories.addAsync call failed with error: " + asyncResult.error.message);
              return reject(false);
            }
          });
        }
        return resolve(true);
      }
    });
  });
};

let addCategory = async function (categoriesToAdd) {
  return new Promise((resolve, reject) => {
    Office.context.mailbox.item.categories.addAsync(categoriesToAdd, function (asyncResult) {
      if (asyncResult.status === Office.AsyncResultStatus.Succeeded) {
        console.log("Successfully added categories");
        return resolve(true);
      } else {
        console.log("categories.addAsync call failed with error: " + asyncResult.error.message);
        return reject(false);
      }
    });
  });
};

Office.onReady((info) => {
  let masterCategoryToBeAdded = [{
    "displayName": "TestCat",
    "color": Office.MailboxEnums.CategoryColor.Preset0
  }];

  getMasterCategories(masterCategoryToBeAdded).then(function (succeeded) {
    if (succeeded) {
      addCategory(["TestCat"]);
    }
  });
});

谢谢

outlook office-js outlook-addin office-addins outlook-web-addins
1个回答
0
投票

尝试调用 SaveAsync 方法使您的更改永久化是有意义的。如果问题仍然存在,我建议将此作为错误发布到https://github.com/OfficeDev/office-js/issues.

© www.soinside.com 2019 - 2024. All rights reserved.