I am running code that looks to add an extended property along with a value. Seems to run fine. When I iterate over the MailItems, I do not see any evidence of the extended property.
Code to extend:
EmailMessage email2 = EmailMessage.Bind(service, result.Items[0].Id);
Guid MyPropertySetId = new Guid("{C11FF724-AA03-4555-9952-
8FA248A11C3E}");
ExtendedPropertyDefinition extendedPropertyDefinition = new
ExtendedPropertyDefinition(MyPropertySetId, "ServiceCat",
MapiPropertyType.String);
email2.SetExtendedProperty(extendedPropertyDefinition, "Level2 big daddy");
email2.Update(ConflictResolutionMode.AlwaysOverwrite);
Code to read extended property:
foreach (Item item in result.Items)
{
Console.WriteLine(item.Subject);
if (item.ExtendedProperties.Count > 0)
{
// Display the name and value of the extended property.
foreach (ExtendedProperty extendedProperty in item.ExtendedProperties)
{
Console.WriteLine(" Extended Property Name: " + extendedProperty.PropertyDefinition.Name);
Console.WriteLine(" Extended Property Value: " + extendedProperty.Value);
}
}
}
I have tried to reconnect to iterate over emails to see if extended property is there but array length remains 0. I.e. the foreach never kicks in.
I am assuming extended preoprty is saved at the exchange "email2.Update(ConflictResolutionMode.AlwaysOverwrite)" and should be able to be read back
Any advice appreciated.