How to remove CompleteName.Title contact with managed EWS api v1.1?

Using the EWS-managed api v1.1, I can successfully save / set the "Contact" contact or an honorable (if you want) non-empty value, but I can’t figure out how to remove it or set it to an empty / null line.

I tried setting an empty value and . I tried to remove the extended property. Here is the relevant code.

var titleDef = new ExtendedPropertyDefinition(0x3A45, MapiPropertyType.String); // works when set to a non-empty string value ewsContact.SetExtendedProperty(titleDef, "Mr."); // throws null argument exception when set to String.Empty or null ewsContact.SetExtendedProperty(propDefinition, String.Empty); // isRemoved is equal to false and the value doesn't change var isRemoved = ewsContact.RemoveExtendedProperty(titleDef); 

I also tried using a different overload in ExtendedPropertyDefinition, as mentioned in this very similar question , but that did not change my final result for deleting the property. I'm not sure I understand the difference in the two signatures for the constructor.

 var titleDef = new ExtendedPropertyDefinition(new Guid("{00062004-0000-0000-C000-000000000046}"), 0x3A45, MapiPropertyType.String); // isRemoved is equal to false and the value doesn't change var isRemoved = ewsContact.RemoveExtendedProperty(titleDef); 

Brute force

I suppose I can take a full copy of the contact (without a name) and delete the original, but this is a bit like the top and is likely to cause other errors.

+4
source share
1 answer

EWS allows you to assign Advanced properties without first binding them. However, to remove an extended property, you need to include it in your initial call to the PropertySet . The following worked for me ...

  var titleDef = new ExtendedPropertyDefinition(0x3A45, MapiPropertyType.String); Contact contact = Contact.Bind(service, id, new PropertySet(titleDef)); contact.RemoveExtendedProperty(titleDef); contact.Update(ConflictResolutionMode.AutoResolve); 

It is also strange that you can get Title as a property of the first class, but you cannot assign it (since it is a complex type). They could make it easier for us.

 var title = contact.CompleteName.Title; 
+4
source

Source: https://habr.com/ru/post/1385607/


All Articles