我正在使用 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/