假设我的 Outlook 加载项(使用 Office.js)中有以下代码在约会的撰写表单上运行:
Let's say I have in my Outlook Add-In (using Office.js) following code running on a compose form of an appointment:
const item = Office.context.mailbox.item;
item.loadCustomPropertiesAsync((result) => {
const props = result.value;
const testProp = props.get("my_prop");
console.log("CUSTOM_PROP", testProp);
props.set("my_prop", "test_value");
props.saveAsync((saveResult) =>
console.log("SAVE_CUSTOM_PROP", saveResult));
});
我明白了,它实际上是保存在事件中的.
I see, that it actually is saved on the event.
现在还有一堆关于这些自定义属性的问题:
And now a bunch of questions regarding those custom properties:
但是那些与扩展属性有某种关系吗?
But are those somehow related to extended properties?
是否可以通过 Outlook REST API 或 Microsoft Graph 以某种方式访问这些属性?
Are those properties somehow accessible through Outlook REST API or Microsoft Graph?
我可以使用 Microsoft Graph 和基于这些属性的筛选器创建推送通知订阅吗?(我知道我可以基于扩展属性)
Can I create a push notifications subscription using Microsoft Graph with a filter based on those properties? (I know I can based on extended properties)
如果上述问题的答案是否",并且自定义属性只能通过创建它们的加载项访问,有没有办法从加载项为事件创建扩展属性,即使没有保存?
If the answer to above question is "no", and the custom properties are only accessible through the add-in which created them, is there a way to create a extended property to an event from the add-in, even if it's not saved?
解释我为什么要问 - 我正在创建一个插件,它允许将约会连接"到我们的第 3 方系统,并使该约会与我们的对象保持同步.
To explain why I'm asking - I'm creating an add-in, which allows to "connect" an appointment with our 3rd party system, and keep that appointment in sync with our object.
所以当点击撰写表单上的按钮时,我:
So when a button is clicked on the compose form, I:
保存约会并获取event-id
, 将其存储在我们的系统中,以便从我们的系统同步到约会.使用 Microsoft Graph 在我们的系统中为该约会添加扩展属性
在首次使用加载项时,用户进行身份验证,然后我使用我们的扩展属性为事件创建推送通知订阅,以便从 Outlook 同步到我们的系统.
In the first use of the add-in, the user authenticates, and I create a push notification subscription for events with our extended property, to do the sync from Outlook to our system.
它在 OWA 上运行良好,但现在我们确实需要支持桌面,因此出现了两个主要问题:
It works great on OWA, but now as we really need to support desktop, two major issues are arising:
Outlook for Mac:没有 saveAsync
方法,因此无法获取事件的 id
,我正在考虑添加一些自定义属性,然后让推送通知通知我们的系统,创建了一个需要与系统外同步的事件.
Outlook for Mac: no saveAsync
method, thus no way to get the event's id
, I was thinking about adding some custom property, and then let the push notification inform our system, that an event was created which needs to be synced with out system.
PC 版 Outlook:有 saveAsync
方法,但回调是在本地保存约会时执行的,而不是在服务器上,因此我无法确切知道事件何时发生已创建,我可以对该事件进行一些 Microsoft Graph 调用.
Outlook for PC: there is the saveAsync
method, but the callback is executed when the appointment is saved locally, not on the server, thus I can't know when exactly the event has been created and I can do some Microsoft Graph calls on that event.
欢迎回答我的第一个问题和/或任何关于我的用例的提示.
Answer to my first question, and/or any tips about my use case would be more than welcome.
TL;DR;是的,可以使用 REST API 读取由 Office.js
api loadCustomPropertiesAsync
设置的自定义属性您需要创建一个 REST 调用查询,如下所示
TL;DR;
Yes it is possible to read custom properties set by Office.js
api loadCustomPropertiesAsync
using REST APIs
You need to create a REST call query that looks like
string addinManifestId = "<your manifest guid here>";//lower cases
string prop = @"String {00020329-0000-0000-C000-000000000046} Name"+ string.Format(" cecp-{0}", addinManifestId );
var url = $"<apiEndpoint>/messages/<youritemid>?$expand=SingleValueExtendedProperties($filter=PropertyId eq '{propertyname}')";
更多信息
文档可在此处获得 https:///msdn.microsoft.com/en-us/library/hh968549(v=exchg.80).aspx
当我需要为我的加载项处理已发送邮件"时,我遇到了类似的问题 Keluro.我使用 REST API 上的网络挂钩实现了一些非常接近您的方法的方法.据我所知,这是处理已发送物品的唯一方法.考虑对此进行投票https://officespdev.uservoice.com/forums/224641-feature-requests-and-feedback/suggestions/10964871-add-itemsend-event-so-add-in-can-cancel-email
I had a similar problem when I needed to handle "sent mail" for my add-in Keluro. I implemented something really close to your approach with a web hook on REST API. To my knowledge it is the only way to handle sent items. Consider upvoting this https://officespdev.uservoice.com/forums/224641-feature-requests-and-feedback/suggestions/10964871-add-itemsend-event-so-add-in-can-cancel-email