[E2007] [EWSMA] [C#]: Multiline Street on Contact Not Working RRS feed

  • Question

  • Exchange Version: 8.1 (Build 240.6)
    API: Exchange Web Services Managed API 1.1
    .NET Version: 3.5
    Outlook Version: 2007

    If I use the EWS Managed API to save a contact that has a multiple-line street address, the line breaks don't appear in the business card view in Outlook, but they do appear if I open the contact to edit it.

    I know similar questions have been asked before in Problem with setting multiple street address lines for a contact as well as in the latter part of the thread Weird Bug in Outlook 2007 and address fields, but I'm wondering, is there any update on the issue?

    Or is the answer still that if I need to save a contact with a multiple-line street address, I can't use the EWS Managed API as-is? I need to use raw XML directly against EWS? Or find a way to override the serialization of the contact? Is overriding that serialization possible?

    For what it's worth, my code is below.

    using System;
    using Microsoft.Exchange.WebServices.Data;
    namespace LineBreakTest
      class Program
        private const string SmtpAddress = "";
        private const string Password = "mypassword";
        private const string Url = "";
        static void Main(string[] args)
          var service = new ExchangeService(ExchangeVersion.Exchange2007_SP1)
            Url = new Uri(Url),
            Credentials = new WebCredentials(SmtpAddress, Password)
          var contact = new Contact(service)
            GivenName = "Foo"
          contact.PhysicalAddresses[PhysicalAddressKey.Business] = 
            new PhysicalAddressEntry {Street = "one\r\ntwo"};
          Console.Write("Done. Press any key to exit...");

    The result in Outlook is that the business card shows the street as 

    But when I open the contact to edit it, the street shows as

    Thanks for any help,
    Friday, February 11, 2011 2:07 PM


  • I ended up going through Microsoft Support to find out the answer to this.

    As-of versions 1.0 and 1.1 of the EWS Managed API, this is a bug. The workaround is the same as that previously described in the thread Weird Bug in Outlook 2007 and address fields.

    You can't use the Managed API to save a line break in a street address. Instead you can either make your request directly against EWS as raw XML or generate a proxy class and edit its code to change the serialization.

    Microsoft has an example of how to change the proxy class's serialization in the article Line Breaks in Managed Web Service Proxy Classes.

    • Marked as answer by amythorne Thursday, March 10, 2011 6:01 PM
    Thursday, March 10, 2011 5:59 PM