Exchange WebService - Errorcode ErrorIncorrectUpdatePropertyCount when updateing contact

Posted on 2012-03-23
Last Modified: 2012-08-13
I use the fallowing method to update a contact in Exchange over EWS:

        private void UpdateContact(Microsoft.Exchange.WebServices.Data.Contact exContact, ContactInfo contact) {
            var pathList = new List<string>();
            try {
                log.DebugFormat("Process ExchangeContact '{0}' with Contact '{1}'", (exContact.IsNew ? "<new>" : exContact.DisplayName), contact.Id);

                exContact.GivenName = contact.AdditionalName;
                exContact.Surname = contact.Name;
                exContact.FileAsMapping = FileAsMapping.SurnameCommaGivenName;

                exContact.CompanyName = "";
                if (contact is PersonInfo) {
                    var person = (PersonInfo) contact;
                    if (person.PersonCompany != null && person.PersonCompany.Company != null) {
                        exContact.CompanyName = person.PersonCompany.Company.DisplayName;
                    exContact.ImAddresses[ImAddressKey.ImAddress1] = person.MessengerName;
                    exContact.ImAddresses[ImAddressKey.ImAddress2] = person.SkypeName;

                // Specify the business, home, and car phone numbers.
                var comm = contact.GetCommunication(Constants.CommunicationType.PhoneBusiness);
                exContact.PhoneNumbers[PhoneNumberKey.BusinessPhone] = (comm != null ? comm.Value : null);
                comm = contact.GetCommunication(Constants.CommunicationType.PhonePrivate);
                exContact.PhoneNumbers[PhoneNumberKey.HomePhone] = (comm != null ? comm.Value : null);
                comm = contact.GetCommunication(Constants.CommunicationType.PhoneMobile);
                exContact.PhoneNumbers[PhoneNumberKey.MobilePhone] = (comm != null ? comm.Value : null);

                comm = contact.GetCommunication(Constants.CommunicationType.MailBusiness);
                exContact.EmailAddresses[EmailAddressKey.EmailAddress1] = (comm != null ? new EmailAddress(comm.Value) : null);
                comm = contact.GetCommunication(Constants.CommunicationType.MailPrivate);
                exContact.EmailAddresses[EmailAddressKey.EmailAddress2] = (comm != null ? new EmailAddress(comm.Value) : null);

                // Specify two IM addresses.

                // Specify the home address.
                var address = contact.AddressList.FirstOrDefault(x => x.AddressType != null && x.AddressType.Id == Constants.AddressType.Private);
                if (address != null) {
                    var paEntry = new PhysicalAddressEntry
                            Street = address.Street,
                            City = address.City,
                            State = address.Region,
                            PostalCode = address.PostalCode,
                            CountryOrRegion = address.CountryName
                    exContact.PhysicalAddresses[PhysicalAddressKey.Home] = paEntry;
                    if (contact.PostalAddress == address) {
                        exContact.PostalAddressIndex = PhysicalAddressIndex.Home;
                } else {
                    exContact.PhysicalAddresses[PhysicalAddressKey.Home] = null;
                address = contact.AddressList.FirstOrDefault(x => x.AddressType != null && x.AddressType.Id == Constants.AddressType.Business);
                if (address != null) {
                    var paEntry = new PhysicalAddressEntry
                            Street = address.Street,
                            City = address.City,
                            State = address.Region,
                            PostalCode = address.PostalCode,
                            CountryOrRegion = address.CountryName
                    exContact.PhysicalAddresses[PhysicalAddressKey.Business] = paEntry;
                    if(contact.PostalAddress == address) {
                        exContact.PostalAddressIndex = PhysicalAddressIndex.Business;
                } else {
                    exContact.PhysicalAddresses[PhysicalAddressKey.Business] = null;

                // Save the contact.
                if (exContact.IsNew) {
                } else {

                pathList.AddRange(this.AddFileAttachments(this.Access.IndependService.GetContact(exContact.Id.UniqueId), contact.GetDocuments()));
            } catch(Exception e) {
                log.Error("Error updating/inserting Contact in Exchange.", e);
            } finally {
                foreach (var path in pathList) {

Open in new window

When I do this for update, I get an Exception with Errorcode ErrorIncorrectUpdatePropertyCount on the line exContact.Update(ConflictResolutionMode.AlwaysOverwrite);

Can someone help me, what is the problem? - Thanks.
Question by:tkehl
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 96

Expert Comment

by:Bob Learned
ID: 37760784
Playing both sides to the middle:

Understanding that error:

ResponseCodeType Enumeration

Indicates that each change description in an UpdateItem or UpdateFolder method call must list only one property to update.
LVL 96

Expert Comment

by:Bob Learned
ID: 37760787
I believe that is one of those errors that isn't helpful.

Another example:

Exchange 2007 Web Services (III): Update a calendar item (UpdateItem)

Pay attention to this line:

calendarEndItem.End = new DateTime(2008, 08, 28, 17, 00, 00);
calendarEndItem.EndSpecified = true;

If we don't set EndSpecified property, we will receive a confusing error code: ErrorIncorrectUpdatePropertyCount.
LVL 96

Expert Comment

by:Bob Learned
ID: 37760802
There is a lot going on there, so it is difficult to see any one thing.  I don't see any loops.  What I would suggest is commenting out the lines that set a property, and then uncomment them until you find the offending line(s).

Accepted Solution

tkehl earned 0 total points
ID: 37820765
I have found the problem.
For empty values, I have to set null instead of "".

Author Closing Comment

ID: 37836682
It is the right solution.

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
In this video we show how to create a mailbox database in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Servers >> Data…
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question