Dictionary mContact.WorkPhone) { updateContact.PhoneNumbers[PhoneNumberKey.BusinessPhone]=customContact.WorkPhone==“”?null:customContact.WorkPhone; } 物理地址; bool-phsicaladdress-found; int phsicaladdress Length=(customContact.Street+customContact.郊区+customContact.City+customContact.Country+customContact.AreaCode)长度; phsicalAddressFound=updateContact.PhysicalAddresses.TryGetValue(PhysicalAddressKey.Home,out phsicalAddress); 如果(找到phsicalAddress) { updateContact.PhysicalAddresses[PhysicalAddressKey.Home].Street=customContact.Street==“”?null:customContact.Street; updateContact.PhysicalAddresses[PhysicalAddressKey.Home].State=customContact.郊区==“”?null:customContact.郊区; updateContact.PhysicalAddresses[PhysicalAddressKey.Home].City=customContact.City==“”?null:customContact.City; updateContact.PhysicalAddresses[PhysicalAddressKey.Home].CountryOrRegion=customContact.Country==“”?null:customContact.Country; updateContact.PhysicalAddresses[PhysicalAddressKey.Home].PostalCode=customContact.AreaCode==“”?null:customContact.AreaCode; } 如果(!phsicalAddressFound&&phsicalAddressLength>0),则为else { updateContact.PhysicalAddresss[PhysicalAddressKey.Home]=家庭地址; } phsicalAddressLength=(customContact.BusinessStreet+customContact.business郊区+customContact.BusinessCity+customContact.BusinessCountry+customContact.BusinessAreaCode)。长度; phsicalAddressFound=updateContact.PhysicalAddresses.TryGetValue(PhysicalAddressKey.Business,out phsicalAddress); 如果(找到phsicalAddress) { updateContact.PhysicalAddresses[PhysicalAddressKey.Business].Street=customContact.BusinessStreet==“”?null:customContact.BusinessStreet; updateContact.PhysicalAddresses[PhysicalAddressKey.Business].State=customContact.Business郊区==“”?null:customContact.Business郊区; updateContact.PhysicalAddresses[PhysicalAddressKey.Business].City=customContact.BusinessCity==“”?null:customContact.BusinessCity; updateContact.PhysicalAddresss[PhysicalAddressKey.Business].CountryOrRegion=customContact.BusinessCountry==“”?null:customContact.BusinessCountry; updateContact.PhysicalAddresses[PhysicalAddressKey.Business].PostalCode=customContact.BusinessAreaCode==“”?null:customContact.BusinessAreaCode; } 如果(!phsicalAddressFound&&phsicalAddressLength>0),则为else { updateContact.PhysicalAddresss[PhysicalAddressKey.Business]=业务地址; } updateContact.Birthday=customContact.Birthdate; updateContact.WeddingAnyVersary=customContact.MaritalStatusDate; //扩展属性------------------------------------------------------------- 扩展属性定义扩展属性定义; //性别 如果(!string.IsNullOrEmpty(customContact.Gender)) { extendedPropertyDefinition=新的extendedPropertyDefinition(0x3a4d,MapPropertyType.Short); 开关(customContact.Gender) { 案件“男”: SetExtendedProperty(extendedPropertyDefinition,2); 打破 “女性”一案: SetExtendedProperty(extendedPropertyDefinition,1); 打破 违约: SetExtendedProperty(extendedPropertyDefinition,3); 打破 } } //头衔 如果(!string.IsNullOrEmpty(customContact.Title)) { extendedPropertyDefinition=新的extendedPropertyDefinition(0x3a45,MapPropertyType.String); updateContact.SetExtendedProperty(extendedPropertyDefinition,customContact.Title); } //后缀 如果(!string.IsNullOrEmpty(customContact.Suffix)) { extendedPropertyDefinition=新的extendedPropertyDefinition(0x3a05,MapPropertyType.String); updateContact.SetExtendedProperty(extendedPropertyDefinition,customContact.后缀); } //自定义属性 extendedPropertyDefinition=新的extendedPropertyDefinition(DefaultExtendedPropertySet.PublicString,“customProperty”,MapPropertyType.String); updateContact.SetExtendedProperty(extendedPropertyDefinition,customContact.CustomProperty); //将联系人归档 updateContact.Subject=customContact.Name+“”+customContact.姓氏; updateContact.DisplayName=customContact.Name+“”+customContact.Name; updateContact.Update(ConflictResolutionMode.AlwaysOverwrite);

Dictionary mContact.WorkPhone) { updateContact.PhoneNumbers[PhoneNumberKey.BusinessPhone]=customContact.WorkPhone==“”?null:customContact.WorkPhone; } 物理地址; bool-phsicaladdress-found; int phsicaladdress Length=(customContact.Street+customContact.郊区+customContact.City+customContact.Country+customContact.AreaCode)长度; phsicalAddressFound=updateContact.PhysicalAddresses.TryGetValue(PhysicalAddressKey.Home,out phsicalAddress); 如果(找到phsicalAddress) { updateContact.PhysicalAddresses[PhysicalAddressKey.Home].Street=customContact.Street==“”?null:customContact.Street; updateContact.PhysicalAddresses[PhysicalAddressKey.Home].State=customContact.郊区==“”?null:customContact.郊区; updateContact.PhysicalAddresses[PhysicalAddressKey.Home].City=customContact.City==“”?null:customContact.City; updateContact.PhysicalAddresses[PhysicalAddressKey.Home].CountryOrRegion=customContact.Country==“”?null:customContact.Country; updateContact.PhysicalAddresses[PhysicalAddressKey.Home].PostalCode=customContact.AreaCode==“”?null:customContact.AreaCode; } 如果(!phsicalAddressFound&&phsicalAddressLength>0),则为else { updateContact.PhysicalAddresss[PhysicalAddressKey.Home]=家庭地址; } phsicalAddressLength=(customContact.BusinessStreet+customContact.business郊区+customContact.BusinessCity+customContact.BusinessCountry+customContact.BusinessAreaCode)。长度; phsicalAddressFound=updateContact.PhysicalAddresses.TryGetValue(PhysicalAddressKey.Business,out phsicalAddress); 如果(找到phsicalAddress) { updateContact.PhysicalAddresses[PhysicalAddressKey.Business].Street=customContact.BusinessStreet==“”?null:customContact.BusinessStreet; updateContact.PhysicalAddresses[PhysicalAddressKey.Business].State=customContact.Business郊区==“”?null:customContact.Business郊区; updateContact.PhysicalAddresses[PhysicalAddressKey.Business].City=customContact.BusinessCity==“”?null:customContact.BusinessCity; updateContact.PhysicalAddresss[PhysicalAddressKey.Business].CountryOrRegion=customContact.BusinessCountry==“”?null:customContact.BusinessCountry; updateContact.PhysicalAddresses[PhysicalAddressKey.Business].PostalCode=customContact.BusinessAreaCode==“”?null:customContact.BusinessAreaCode; } 如果(!phsicalAddressFound&&phsicalAddressLength>0),则为else { updateContact.PhysicalAddresss[PhysicalAddressKey.Business]=业务地址; } updateContact.Birthday=customContact.Birthdate; updateContact.WeddingAnyVersary=customContact.MaritalStatusDate; //扩展属性------------------------------------------------------------- 扩展属性定义扩展属性定义; //性别 如果(!string.IsNullOrEmpty(customContact.Gender)) { extendedPropertyDefinition=新的extendedPropertyDefinition(0x3a4d,MapPropertyType.Short); 开关(customContact.Gender) { 案件“男”: SetExtendedProperty(extendedPropertyDefinition,2); 打破 “女性”一案: SetExtendedProperty(extendedPropertyDefinition,1); 打破 违约: SetExtendedProperty(extendedPropertyDefinition,3); 打破 } } //头衔 如果(!string.IsNullOrEmpty(customContact.Title)) { extendedPropertyDefinition=新的extendedPropertyDefinition(0x3a45,MapPropertyType.String); updateContact.SetExtendedProperty(extendedPropertyDefinition,customContact.Title); } //后缀 如果(!string.IsNullOrEmpty(customContact.Suffix)) { extendedPropertyDefinition=新的extendedPropertyDefinition(0x3a05,MapPropertyType.String); updateContact.SetExtendedProperty(extendedPropertyDefinition,customContact.后缀); } //自定义属性 extendedPropertyDefinition=新的extendedPropertyDefinition(DefaultExtendedPropertySet.PublicString,“customProperty”,MapPropertyType.String); updateContact.SetExtendedProperty(extendedPropertyDefinition,customContact.CustomProperty); //将联系人归档 updateContact.Subject=customContact.Name+“”+customContact.姓氏; updateContact.DisplayName=customContact.Name+“”+customContact.Name; updateContact.Update(ConflictResolutionMode.AlwaysOverwrite);,dictionary,title,exchangewebservices,contact,Dictionary,Title,Exchangewebservices,Contact,您是否尝试过使用Microsoft在中使用的方式来更新业务地址: PhysicalAddressEntry PABusinessEntry = new PhysicalAddressEntry(); PABusinessEntry.Street = "4567 Contoso Way"; PABusinessEntry.City = "Redmond"; PABusinessEntry.State = "OH"; PABusinessEntry.PostalCode = "33333"; PAB

您是否尝试过使用Microsoft在中使用的方式来更新业务地址:

PhysicalAddressEntry PABusinessEntry = new PhysicalAddressEntry();
PABusinessEntry.Street = "4567 Contoso Way";
PABusinessEntry.City = "Redmond";
PABusinessEntry.State = "OH";
PABusinessEntry.PostalCode = "33333";
PABusinessEntry.CountryOrRegion = "United States of America";
contact.PhysicalAddresses[PhysicalAddressKey.Business] = PABusinessEntry;
这样就创建了一个新的PhysicalAddressEssentry对象,它可能会解决您的问题


(当然,这对电话号码没有帮助。)

Hi Marc,您是否在没有从EWS收到此错误消息的情况下清除了电子邮件地址?错误:“更改描述中的对象必须包含且仅包含一个要修改的属性。”如果我将电子邮件地址设置为“-”,则可以正常工作。一旦我把它设置为String.Empty或null,我就得到了错误。嗨,卡尔,据我所知,如果你想要它为空,你必须将它设置为null。不能将其设置为string.Empty。此外,仅在找到电子邮件地址时设置该地址。使用Contact.EmailAddresses.TryGetValue()-返回布尔值。如果没有电子邮件地址,则不能将其设置为空。另一件要检查的事情是所有其他属性——确保它们也都设置正确(并且在尝试之前找到它们)。您可能设置不正确,电子邮件地址也没有问题。@MarcK的情况在6年后仍然是一样的。我不明白为什么不能简单地在updateContact和save中设置所有值。不考虑某个特定字段是否已更新。我想说,这是一种实现API的荒谬方式。我尝试使用
contact.PhoneNumbers[PhoneNumberKey.BusinessFax]
设置传真号码,但它在传真和扫描中没有检测为传真号码(显示为无效)。我将传真另存为扩展属性,但我不知道如何设置。这看起来会很好地工作。在我的代码中,如果找不到地址,我会为相关的地址条目分配一个新的地址条目