Aar*_*ner 4 exchangewebservices ews-managed-api
使用EWS托管api v1.1,我可以成功保存/设置联系人"标题"或敬意(如果您愿意)为非空值,但我无法弄清楚如何删除或将其设置为空串/空.
我试图设置一个空值,我试图删除扩展属性.这是相关的代码.
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);
Run Code Online (Sandbox Code Playgroud)
我也尝试在这个非常相似的问题中提到的ExtendedPropertyDefinition上使用不同的重载,但它并没有改变我删除属性的最终结果.我不确定我理解构造函数的两个签名的区别.
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);
Run Code Online (Sandbox Code Playgroud)
蛮力解决方案
我想我可以拿一份联系人的完整副本(没有标题)并删除原文,但这似乎有点过头,可能会导致其他错误.
EWS允许您在不先绑定它们的情况下分配扩展属性.但是,要删除扩展属性 - 您需要将其包含在初始绑定调用中PropertySet
.以下对我有用......
var titleDef = new ExtendedPropertyDefinition(0x3A45, MapiPropertyType.String);
Contact contact = Contact.Bind(service, id, new PropertySet(titleDef));
contact.RemoveExtendedProperty(titleDef);
contact.Update(ConflictResolutionMode.AutoResolve);
Run Code Online (Sandbox Code Playgroud)
同样奇怪的是,您可以将标题检索为第一类属性,但您无法分配它(因为它是复杂类型).他们本可以让我们更轻松.
var title = contact.CompleteName.Title;
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1050 次 |
最近记录: |