OfficeDev / ews-managed-api

Other
584 stars 319 forks source link

Physical address order of Zip/City #183

Closed jochenkluger closed 6 years ago

jochenkluger commented 6 years ago

Hello, I am using EWS to add contact items to an office365 account. Everything works fine, just one detail is not as expected. When I create a new contact and add e.g. the home address like this:

if (ewsContact.PhysicalAddresses.Contains(PhysicalAddressKey.Home) == false)
{
   ewsContact.PhysicalAddresses[PhysicalAddressKey.Home] = new PhysicalAddressEntry();
}
if (string.IsNullOrEmpty(contact.HomeZip) == false)
{
   ewsContact.PhysicalAddresses[PhysicalAddressKey.Home].PostalCode = contact.HomeZip;
}
if (string.IsNullOrEmpty(contact.HomeCity) == false)
{
   ewsContact.PhysicalAddresses[PhysicalAddressKey.Home].City = contact.HomeCity;
}

The data is written to the contact item, but in the combined field and on the card view in Outlook the ordering of Zip and City is always the order that is used in the US - e.g. Washington 98155 As I have a lot of addresses from europe, I need the correct order - e.g. 10115 Berlin. If I open the contact in Outlook, change the Zip code at one position and save it back, the order is saved correctly and the display in Outlook is correct.

Is there any way to have the correct order with EWS?

jochenkluger commented 6 years ago

This issue was solved by a post on stackoverflow - https://stackoverflow.com/questions/49842350/physical-address-order-of-zip-city .

The solution is to set the address manually using the PidLidWorkAddress.