Reputation: 321
I would like to read all "Custom properties" from EWS-Items. I do have the names of the properties (e.g. "duration" oder "distance") but I did not create them (my clients did).
I guess I will have to use "ExtendedProperties" of the "Item" class. But when I use Item.Bind() with a Property-set I need to know a GUID which I don't have! Microsoft says (http://msdn.microsoft.com/en-us/library/exchange/dd633697%28v=exchg.80%29.aspx): "Create a GUID identifier from the GUID that was used when the extended property was created."
I don't have these GUIDs because I did not create the properties. I guess the only chance is to use Item.Bind() without a specific property set. Would that slow down the process (I need to call this for every item in the mailbox)?
I basically would like to iterate with a clause like this: if (extendedProperty.PropertyDefinition.Name == "duration")
Any ideas how to do this?
Thanks
Martin
Upvotes: 0
Views: 1226
Reputation: 11063
try to recover it by name using the PropertyDefinition and property type (MapiPropertyType):
//Search for "duration" property
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
}
Upvotes: 1