【问题标题】:Read ExtendedProperties from Outlook Add-In从 Outlook 加载项读取 ExtendedProperties
【发布时间】:2016-12-23 07:15:56
【问题描述】:

我目前正在使用 EWS 托管 API (C#) 在 CalendarFolder 上设置自定义 ExtendedProperties

myCalendar.SetExtendedProperty(customExtendedProperty, true);

我还可以在绑定CalendarFolder 时使用托管 API 来加载这些设置:

var myCalendar = CalendarFolder.Bind(service, folderId, requestedPropertySet);

接下来我想阅读这些相同的 ExtendedProperties,但来自使用 Office JavaScript 库的 Outlook 加载项。

从 Outlook 库的外观来看,没有公开任何来自Office.context.item 的方法来访问ExtendedProperties

库中是否有允许我访问它的方法?如果没有,我可以使用在 URL 路径中具有 GUID 的架构方法("http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/yourProp")吗?

【问题讨论】:

    标签: javascript outlook-addin exchangewebservices extended-properties


    【解决方案1】:

    要在 Addin 中访问您自己的文件夹上的自定义属性,您需要使用 makeEwsRequestAsync https://dev.outlook.com/reference/add-ins/Office.context.mailbox.html#makeEwsRequestAsync 在您的 Addin 中执行 GetFolder。要获得正确的 SOAP 消息,只需在您的 EWS 托管 API 代码中启用跟踪,该代码将输出使用的 SOAP https://msdn.microsoft.com/en-us/library/office/dn495632(v=exchg.150).aspx,您可以将其转置。需要注意的一件事是在您的应用程序中创建 makeEwsRequestAsync 的安全要求,例如 ReadWriteMailbox http://dev.office.com/docs/add-ins/outlook/understanding-outlook-add-in-permissions

    【讨论】:

    • 我不知道有一种方法可以分析发送的 SOAP 消息。那是缺失的部分。谢谢!
    【解决方案2】:

    截至目前(2018 年 7 月),在编写 Outlook 加载项时访问自定义 ExtendedProperties 的首选方法是使用 ExtendedProperties REST API

    有一些示例代码展示了如何将 API 与 Office 插件 JavaScript 库一起使用,可从Office Dev Center 获得。

    要使用 API,您需要从当前 Outlook 邮箱中获取身份验证令牌。这可以使用Office.context.mailbox.getCallbackTokenAsync() 方法和关键字参数{isRest: true} 来完成。您还应该使用Office.context.mailbox.restUrl 属性来获取API 调用的正确基本URL。

    实际上有几种方法可以从 JavaScript 进行 REST API 调用,但最简单的在客户端进行调用的方法是使用 AJAX 调用。在您的示例中,这看起来像:

    const getMessageUrl = Office.context.mailbox.restUrl
      + "/v2.0/me/mailFolders/" + <folder id> + "?"
      + "$expand=singleValueExtendedProperties"
      + "($filter=PropertyId eq '<property id>')";
    
    $.ajax({
      url: getMessageUrl,
      datatype: 'json',
      headers: {'Authorization': 'Bearer ' + <auth token>}
    }).then(item => {
      // your code here
    })
    

    如果您的资产有 GUID,则 将如下所示:

    "String {00020329-0000-0000-C000-000000000046} Name yourProp"
    

    如果您像我一样尝试访问早于 GUID 规则的属性,那么您的 可能如下所示:

    "String 0x007D"
    

    【讨论】:

      猜你喜欢
      • 2012-12-30
      • 1970-01-01
      • 2021-06-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-24
      • 1970-01-01
      相关资源
      最近更新 更多