访问VSTO for Outlook中的项目时如何访问使用EWS设置的扩展属性 [英] How to access extended properties set with EWS when accessing the item in VSTO for Outlook

查看:65
本文介绍了访问VSTO for Outlook中的项目时如何访问使用EWS设置的扩展属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

情况是这样的:有一个导出到Outlook的应用程序,然后有一个Outlook附件,其中将数据发送到您的应用程序.可以很容易地以两种方式发送信息,然后在Outlook中使用用户属性创建Outlook项目,或者在应用程序中使用EWS和扩展属性创建项目.

The scenario is this: have an app which exports to Outlook and then have an Outlook add in which sends data to your app. It is easy enough to send info either way and then in Outlook to create an Outlook item with a user property or in the app to create the item using EWS and use the extended properties.

设置扩展属性的方法如下:

The way to set the extended property is as follows:

    extendedPropertyDefinition = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.PublicStrings, "CustomProperty", MapiPropertyType.String);
    contact.SetExtendedProperty(extendedPropertyDefinition, customPropertyValue);

那么如何在Outlook加载项中访问由应用程序设置的扩展属性(使用EWS)?

So how do you access the extended properties set by your app (using EWS) in the Outlook add in?

推荐答案

在加载项中,并不仅仅是找到定义为UserProperty的属性.因此,需要使用PropertyAccessor访问该属性,为此您需要扩展属性的架构.这在联机文档中不容易找到,但是我设法发现这些PublicStrings扩展属性的架构为:

In the add in, one does not simply find this property defined as a UserProperty. Therefore the property needs to be accessed using the PropertyAccessor, for which you need the schema of the extended property. This is not easy to find in online documentation, but I managed to find out that the schema for these PublicStrings extended properties is:

" http://schemas.microsoft.com/mapi/string/ {00020329-0000-0000-C000-000000000046}/CustomProperty"

"http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/CustomProperty"

请注意,如果您使用PropertyAccessor,但Outlook项上不存在该属性,则会引发COM异常,因此必须进行try-catch才能返回空值.

Note that if you use the PropertyAccessor and the property does not exist on the Outlook item, a COM exception will be thrown, so a try-catch is necessary in order to return an empty value.

这篇关于访问VSTO for Outlook中的项目时如何访问使用EWS设置的扩展属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆