使用EWS在Exchange Server上读取所有自定义属性

时间:2013-05-14 09:56:13

标签: exchange-server exchangewebservices

我想阅读EWS-Items中的所有“自定义属性”。我确实有属性的名称(例如“持续时间”或“距离”)但我没有创建它们(我的客户确实)。

我想我将不得不使用“Item”类的“ExtendedProperties”。但是当我将Item.Bind()与Property-set一起使用时,我需要知道一个我没有的GUID!微软称(http://msdn.microsoft.com/en-us/library/exchange/dd633697%28v=exchg.80%29.aspx): “从创建扩展属性时使用的GUID创建GUID标识符。”

我没有这些GUID,因为我没有创建属性。 我想唯一的机会是使用没有特定属性集的Item.Bind()。这会减慢进程吗(我需要为邮箱中的每个项目调用它)?

我基本上想要使用这样的子句进行迭代: if(extendedProperty.PropertyDefinition.Name ==“duration”)

任何想法如何做到这一点?

谢谢

马丁

1 个答案:

答案 0 :(得分:1)

尝试使用PropertyDefinition和属性类型(MapiPropertyType)按名称恢复它:

//搜索“持续时间”属性

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

    EmailMessage msgMod = EmailMessage.Bind(service, msgComplete.Id, 
                          new PropertySet(extendedPropertyDefinition));

    ExtendedPropertyCollection colProp = msgMod.ExtendedProperties;
    foreach (ExtendedProperty prop in colProp)
    {

       //Iterate properties

    }
相关问题