在Outlook插件中从EWS获取ExtendedPropertyDefinition值

3

我正在使用 EWS webservices 对邮箱执行自动化流程,并像这样为邮件分配 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;
1个回答

3

好的,最终我搞定了。我必须使用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");

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接