2

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....

zombiecode
  • 353
  • 1
  • 11
  • Any similarity to this S/O solution? http://stackoverflow.com/questions/3304157/error-when-i-try-to-read-update-the-body-of-a-task-via-ews-managed-api-you-m – tgolisch May 16 '17 at 18:52

1 Answers1

2

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);
Glen Scales
  • 20,495
  • 1
  • 20
  • 23