我可以在 outlook javascript 的 MessageComposeCommandSurface 中获取休息令牌吗?

Can i fetch a rest token while in MessageComposeCommandSurface in outlook javascript?

当我的扩展程序从 MessageReadCommandSurface ExtensionPoint 打开时,我可以获得一个令牌并请求用户联系,但是如果我的 ExtensionPoint 更改为 MessageComposeCommandSurface,我对 getCallbackTokenAsync 的调用将失败并显示以下内容。

{
  "name": "CanOnlyGetTokenForSavedItem",
  "message": "The token can't be retrieved until the item is saved.",
  "code": 9029
}

我的代码 运行 相当简单。

Office.initialize = 
    () => Office.context.mailbox.getCallbackTokenAsync({ isRest: true }, 
    res => console.log(res));

是否可以在消息撰写窗格中从我的加载项查询用户的联系人?

如错误提示,您可以 save the item 并在保存项目后获取令牌。

Office.context.mailbox.item.saveAsync(
  function callback(result) {
    // Process the result
  });

Office.context.mailbox.getCallbackTokenAsync() 预计 return 范围为项目的令牌。(具有 ReadWriteMailbox 权限的加载项除外),因此预计项目将被保存。