outlook - 运行 Outlook COM 加载项(在 Windows 上的本机 Outlook 中)时,如何使用 Office.js API 获取委派日历的用户电子邮件?
问题描述
我正在开发一个 Outlook Web 插件并在 Windows 上的本机 Outlook 2019 中运行它。我的同事将他的日历委托给我,我可以访问他的日历,并且可以在共享日历的约会中运行我的网络插件。我正在使用 F12 开发人员工具查看控制台日志。所以,对我来说主要问题 - 获取共享日历的用户电子邮件。我试图得到Office.context.mailbox.item.organizer
,但在 F12 DevTools 的控制台中我看到了undefined
。当我尝试进入Office.context.mailbox.item
F12 Devtools 的控制台时,我看到[object] { }
但我不知道如何查看所有对象属性。
在manifest.xml
我的加载项中,我添加了<SupportsSharedFolders>true</SupportsSharedFolders>
,但它对我没有帮助(我认为只有当我在功能区中看不到我的加载项时才需要它,但我已经在没有此参数行的情况下看到了它)。
我还尝试将权限manifest.xml
从“ReadWriteItem”更改为“ReadWriteMailbox” - 没有更改。
我查看了官方的 Microsoft 文档,在那里我读到我可以使用我调用的参数(链接到官方文档)调用Office.context.mailbox.item.saveAsync
并作为回调函数传递,并且调用没有问题(除了我无法访问和可以的字段)由于 F12 Devtools,t 实际上看到控制台中有哪些字段),但在 F12 Devtools 的控制台中我看到了更多。如果调用此方法,我将执行以下操作:asyncResult0
Office.context.mailbox.getCallbackTokenAsync
saveAsync
asyncResult0.value
asyncResult0
Object doesn't support property or method 'getCallbackTokenAsync', TypeError: Object doesn't support property or method 'getCallbackTokenAsync'
Office.context.mailbox.item.saveAsync(function (asyncResult0) {
Office.context.mailbox.getCallbackTokenAsync({
isRest: true
},
function (asyncResult) {
if (asyncResult.status === Office.AsyncResultStatus.Succeeded && asyncResult.value !== "") {
Office.context.mailbox.item.getSharedPropertiesAsync({
// Pass auth token along.
asyncContext: asyncResult.value
},
function (asyncResult1) {
const sharedProperties = asyncResult1.value; // may be it contains shared calendar user email
// some operations...
}
);
}
}
);
});
重要细节:
- 在
manifest.xml
:
- 要求集 MinVersion 1.1
- 要求集 DefaultMinVersion 1.3
- 而且我不知道我是否正确使用了 Microsoft 文档。
我在共享日历中创建了一份约会草稿,并尝试了该草稿中上述所有内容。
我不知道如何更正确地调试 COM 插件(基于 Web 版本),现在我只知道 F12 Devtools。
我不知道它是否重要,但以防万一我在 Office 365 中运行我的加载项时写下(仅在我的日历的约会中,因为加载项没有
<SupportsSharedFolders>true</SupportsSharedFolders>
在 Office 365 中安装,没有它我可以'在共享日历中看不到加载项)我可以Office.context.mailbox.item
在控制台中看到对象的所有属性。Office.context.mailbox.item.organizer
返回带有方法的对象getAsync
,如果我调用该方法(并使用参数作为回调函数传递result
),我会得到result
:({ status: "succeeded", value: { displayName: "...", emailAddress: "..." } }
在这种情况下,当然是我的用户的数据)。而且我还能够获得asyncResult0
传递给的回调saveAsync
,以及asyncResult
传递给的回调getCallbackTokenAsync
。但是getSharedPropertiesAsync
在控制台中调用时,我看到“Office.context.mailbox.item.getSharedPropertiesAsync 不是函数”。在本机 Outlook 加载项中,使用
Office = window.external
对象作为 Office JS API 点。Office.context.mailbox.diagnostics.hostVersion
在控制台显示:16.0.0.10368
请帮帮我。我不知道如何在 Appointment with Office.js API 中获取共享日历的用户电子邮件。我会很高兴任何线索。
此致!
解决方案
在共享日历/文件夹中,您只能通过调用Office.context.mailbox.item.getSharedPropertiesAsync获取所有者的电子邮件地址。在您自己的日历/文件夹(非共享)中,该getSharedPropertiesAsync
API 不存在,因为您可以简单地调用Office.context.mailbox.item.organizer
以获取约会/会议所有者的电子邮件地址。
推荐阅读
- python - api.retweets 未检索到转推的写入数
- r - regarding transforming an nd array structure into dataframe and save it using feather library
- php - HTML 文件输入将大括号返回给 Laravel 控制器
- java - 如何在保持场景响应的同时在所有内容之上添加另一个窗格?
- python - 顶点是边的两倍
- python - 在他们所在的所有服务器中取消静音成员
- python - 如何使用函数找到单词在列表中的位置?
- python - AttributeError:张量没有属性 Child
- c# - 命令聚合失败:来自 mongot :: 的远程错误由 :: \"origin\" 引起,必须是日期、数字或 geoPoint(来自 \"compound.should[1].near\")
- python-3.x - 如何将列表中的所有元组组合到一个列表中?还将列表中的第一行与所有其他行进行比较