c# - 从 Outlook 插件中的 EWS 获取 ExtendedPropertyDefinition 值

标签 c# winforms outlook-addin exchangewebservices

我正在使用 EWS 网络服务对邮箱进行自动处理,并将 ExtendedPropertyDefinition 分配给这样的消息:

Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition extendedPropertyDefinition =
                           new Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition(DefaultExtendedPropertySet.Common, "Archivado", MapiPropertyType.String);

  msgComplete.SetExtendedProperty(extendedPropertyDefinition, iddoc);
                             msgComplete.Update(ConflictResolutionMode.AlwaysOverwrite);

另一方面,我正在开发一个 Outlook 插件,如果该消息定义了这个 ExtendedPropertyDefinition 名称,它需要评估每次消息点击,但我不知道如何从中恢复扩展属性使用 Outlook 类的 outlook 插件。

我不介意是否必须使用另一种属性才能从两个框架访问。

我曾尝试在 Outlook 中使用以下属性,但没有成功;

item.Userproperties;

item.PropertyAccesor.GetProperty("Archivado"); 

item.ItemProperties;

最佳答案

好吧,我终于明白了。我必须使用 Guid 创建 ExtendedPropertyDefinition 并使用属性上的架构从 Outlook 中恢复它,如下所示:

//Setting the property with Exchange webservice:

string guid = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";

Guid MY_PROPERTY_SET_GUID = new Guid(guid); 

Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition extendedPropertyDefinition =
new Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition(MY_PROPERTY_SET_GUID, "Archivado", MapiPropertyType.String);


//Recover the property using Outlook:


Outlook.MailItem item = (Outlook.MailItem)e.OutlookItem;

Outlook.UserProperties mailUserProperties = item.UserProperties;

dynamic property=item.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/string/{Outlook.MailItem item = (Outlook.MailItem)e.OutlookItem;

            Outlook.UserProperties mailUserProperties = item.UserProperties;
            dynamic property=item.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/string/{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}/Archivado");

关于c# - 从 Outlook 插件中的 EWS 获取 ExtendedPropertyDefinition 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15153191/

相关文章:

c# - 在 C# 中为 ASP.NET 重写方法时,我应该调用基类实现吗?

c# - GetAllNetworkInterfaces 需要一些垃圾

c# - 具有 BindingList<T> 和 DataGridView 的多线程 C# 应用程序

c# - 如何限制右键单击仅选定的 ListView 项目或项目而不是空白空间?

c# - 使用不同的屏幕自动调整 outlook 自定义任务 Pane 的大小

c# - 在 Outlook mailitem.To 字段中设置焦点使用 c#?

c# - 将 DataTable 转换为 ObservableCollection(没有特定类)

c# - 如何通过单击wpf中的按钮来使用TabIndex导航光标?

c# - PictureBox - 处理图像非透明区域的点击事件

visual-studio - Outlook 加载项 VSTO : Ribbon Type property is not shown