Reputation: 325
I'm trying to update an existing email with a new property but I can't get it working.. i'm testing it by adding a custom property with a time stamp string in it..
When i fetch the item in after this has run I can't see any extended properties on it at all...
Here's how i'm trying to save it:
message.Load();
Guid MyPropertySetId = new Guid("{117c7745-5df5-4049-97be-8e2d2d92d566}");
ExtendedPropertyDefinition extendedPropertyDefinition = new ExtendedPropertyDefinition(MyPropertySetId, "JNB", MapiPropertyType.String);
message.SetExtendedProperty(extendedPropertyDefinition, DateTime.Now.AddDays(2).ToString());
message.Update(ConflictResolutionMode.AlwaysOverwrite);
And then when I pull it back in again i'm doing this:
if (item.ExtendedProperties.Count > 0)
{
// Display the name and value of the extended property.
foreach (ExtendedProperty extendedProperty in item.ExtendedProperties)
{
if (extendedProperty.PropertyDefinition.Name == "ccpUniqueID")
{
messageAlreadyLogged = AccountMessageManager.HasMessageAlreadyBeenSaved(extendedProperty.Value.ToString());
}
}
}
There just isn't any extended properties....
Upvotes: 2
Views: 1010
Reputation: 22032
Exchange will only return the Extended properties you tell it to return so in your case you will need to add that property to a Property Set and then use Load to load it back (this won't happen by default) eg
Guid MyPropertySetId = new Guid("{117c7745-5df5-4049-97be-8e2d2d92d566}");
ExtendedPropertyDefinition extendedPropertyDefinition = new ExtendedPropertyDefinition(MyPropertySetId, "JNB", MapiPropertyType.String);
PropertySet psPropSet = new PropertySet(BasePropertySet.FirstClassProperties){extendedPropertyDefinition};
message.Load(psPropSet);
Upvotes: 2