代码之家  ›  专栏  ›  技术社区  ›  MK446

Outlook Rest API推送通知:根据Outlook加载项设置的特定自定义属性筛选通知

  •  2
  • MK446  · 技术社区  · 8 年前

    我遵循了中提到的相同步骤 this question

    下面是我订阅推送通知时使用的资源链接。

    https://outlook.office.com/api/v2.0/me/events/?$filter=SingleValueExtendedProperties%2FAny(ep%3A%20ep%2FPropertyId%20eq%20'String%20{00020329-0000-0000-C000-000000000046}%20Name%20cecp-7e248e5e-204e-4e2b-aa0f-788af20fc21c'%20and%20ep%2FValue%20ne%20null)
    

    它过滤具有由外接程序设置的自定义属性的日历项,而不管它是什么自定义属性。

    自定义属性1:

    var item = Office.context.mailbox.item;
    item.loadCustomPropertiesAsync((result) => {
         const props = result.value;
         props.set("my_prop_one", "test_value_one");
         props.saveAsync((saveResult) => console.log("Successfull"));
     });
    

    自定义属性2:

    var item = Office.context.mailbox.item;
     item.loadCustomPropertiesAsync((result) => {
          const props = result.value;
          props.set("my_prop_two", "test_value_tw");
          props.saveAsync((saveResult) => console.log("Successful"));
     });
    

    现在,我想筛选所有具有自定义属性的日历项 my_prop_one .

    正如@Jason Johnston在其中一条评论中所建议的那样,我使用MFCMapi交叉验证了属性名及其GUID。属性名及其GUID值都正确。

    meetingsetby .

    会议挫折 它的价值 webex .

    https://outlook.office.com/api/v2.0/Me/Events?$filter=SingleValueExtendedProperties%2FAny(ep%3A%20ep%2FPropertyId%20eq%20'String%20{00020329-0000-0000-C000-000000000046}%20Name%20meetingsetby'%20and%20ep%2FValue%20eq%20'webex')
    

    下面是来自 postman 当我使用上面的url进行get调用时。

    会议挫折 和价值

    然后我设置 SingleValueExtendedProperty 使用outlook Rest API创建日历项,如中所述 this post Outlook Rest API request to set Single Value Extended Property

    SingleValueExtendedProperty MFCMapi data of SingleValueExtendedProperty

    然后,我从MFCMapi收集数据,并准备下面的url来过滤正在使用的日历项 singleValueExtendedProperty 在上述步骤中设置。

    https://outlook.office.com/api/v2.0/Me/Events?$filter=SingleValueExtendedProperties%2FAny(ep%3A%20ep%2FPropertyId%20eq%20'String%20{6666AA44-4659-4830-9070-00047EC6AC6E}%20Name%20RestApiSingleValueExtendedProperty'%20and%20ep%2FValue%20eq%20'Set this property using REST API')
    

    下面是来自 邮递员 Filter response based on singleValueExtendedProperty

    如您所见,我可以使用 . 但我的要求是过滤由outlook web加载项设置了特定自定义属性的日历项。

    欢迎提供任何建议/答案。

    1 回复  |  直到 8 年前
        1
  •  1
  •   Jason Johnston    8 年前

    由外接程序设置的自定义属性(使用 CustomProperties 接口)是 等效于普通MAPI命名属性。本质上,插件API所做的是获取所有“自定义属性”,将它们序列化为JSON负载,然后将其保存在单个MAPI命名的属性中,该属性将具有名称 cecp-{some guid} ,以及属性集GUID PS_PUBLIC_STRINGS {00020329-0000-0000-C000-000000000046} {some-guid} 部分名称等于 Id 您的加载项。这都在 MS-OXCEXT section 2.2.5

    $filter 关于您在 CustomProperties 接口,因为没有 SingleValueExtendedProperty 具有该名称和值。相反,只有一个 使用名称 自定义属性

    那你怎么能做你想做的?好的,回到您的原始URL,您可以通过执行以下操作获得所有具有由外接程序设置的任何属性的消息

    $filter=SingleValueExtendedProperties/Any
      (ep: ep/PropertyId eq 'String {00020329-0000-0000-C000-000000000046} 
      Name cecp-7e248e5e-204e-4e2b-aa0f-788af20fc21c' and ep/Value ne null)
    

    将GUID替换为 cecp-

    当然,你只想找到那些具有特定属性的( meetingsetby )设置为特定值( webex SingleValueExtendedProperties . 因此,您需要做的是获取具有外接程序设置的任何属性的所有消息,然后执行您自己的过滤逻辑以找到您想要的消息。所以基本上你会把它们加载到内存中,然后自己检查这个属性的值,找到你想要的。

    您可以通过使用 $expand

    ?$filter=SingleValueExtendedProperties/Any
      (ep: ep/PropertyId eq 'String {00020329-0000-0000-C000-000000000046} 
      Name cecp-7e248e5e-204e-4e2b-aa0f-788af20fc21c' and ep/Value ne null)
      &$expand=SingleValueExtendedProperties($filter=PropertyId eq 'String
      {00020329-0000-0000-C000-000000000046} Name cecp-7e248e5e-204e-4e2b-aa0f-788af20fc21c')