简体   繁体   English

使用来自EWS或REST API的office365 JS API访问CustomProperties

[英]Access CustomProperties set using office365 JS APIs from EWS or REST API

I have an office 365 mail app that stores a value in a custom property before the item is saved. 我有一个Office 365邮件应用程序,它在保存项目之前将值存储在自定义属性中。 When the item is saved I want to access this property using a server-side application. 保存项目时,我想使用服务器端应用程序访问此属性。 Reading through the custom properties documentation tells me I can't access custom properties created using the JS API using any other service like EWS since these are not MAPI properties. 阅读自定义属性文档告诉我,我无法使用任何其他服务(如EWS)访问使用JS API创建的自定义属性,因为这些不是MAPI属性。 Are there any workarounds ? 有没有解决方法? Is it possible to access these using REST APIs ? 是否可以使用REST API访问这些?

Actually, it is documented where they are stored and in what format. 实际上,它记录了它们存储的位置和格式。 The [MS-OXCEXT] specification provides the specifics. [MS-OXCEXT]规范提供了具体细节。 Basically the values are stored as a JSON dictionary in a custom property on the item. 基本上,这些值作为JSON字典存储在项目的自定义属性中。 You should be able to use EWS to read that custom property as an ExtendedProperty . 您应该能够使用EWS将该自定义属性读取为ExtendedProperty

UPDATE: After discussing with folks internally, I should disclaim that this isn't a supported method as MrPiao indicated. 更新:在与内部人士讨论后,我应该否认这不是像MrPiao所说的那样支持的方法。 As stated, the storage design could change, which would break your app if you depend on the current design. 如上所述,存储设计可能会发生变化,如果您依赖于当前的设计,这会破坏您的应用。 The concern is that I don't want to lead you down a path that eventually becomes unworkable :). 关注的是,我不想引导你走上最终变得不可行的道路:)。 If you can describe what your end goal is, perhaps we can suggest a more durable solution. 如果您可以描述您的最终目标,也许我们可以建议更持久的解决方案。

Custom Properties are definitely meant to be created and accessed only by Apps for Outlook APIs. 自定义属性绝对只能由Apps for Outlook API创建和访问。 However , this property has to get stored somewhere - and that's on the item. 但是 ,这个属性必须存储在某个地方 - 这就是项目。 I'm fairly certain that if you made a GetItem call and enumerated every property on the item, you'll be able to access the custom props. 我相当肯定,如果你进行了一个GetItem调用并枚举了该项目的每个属性,你将能够访问自定义道具。

What's important to note is that this is most definitely an unsupported scenario . 需要注意的是,这绝对是一个不受支持的场景 The design may change in the future, and this scenario may break. 设计可能在未来发生变化,这种情况可能会中断。 I would definitely not access custom properties outside a Mail App in a production setting. 我绝对不会在生产环境中访问Mail App外的自定义属性。

Guid PS_PUBLIC_STRINGS = new Guid("00020329-0000-0000-C000-000000000046"); ////PS_PUBLIC_STRINGS' GUID
ExtendedPropertyDefinition extendedPropertyDefinition = new ExtendedPropertyDefinition(PS_PUBLIC_STRINGS, "cecp-{your add-in manifest id}", MapiPropertyType.String);
PropertySet psPropSet = new PropertySet() { extendedPropertyDefinition };

message.Load(psPropSet);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM