none
[EWSMA][C#]EWS writing LegacyDN address instead of SMTP to contacts RRS feed

  • Question

  • I'm currently attempting to implement a service which uses EWS to make updates to the outlook contacts of users but I'm having a bit of trouble correctly writing to the email address fields. Note that I'm not an Exchange developer and I'm a newbie when it comes to EWS.

    When using the FindItems() method to search a user's contacts folder, the returned Contact objects have their email address fields as the correct SMTP address (blah@blah.com). However, when I update and save the contact, the next I time retrieve that contact, the email address field displays the LegacyDN address (/o=Blah/ou=Exchange Administrative Group/cn=Recipients/cn=Blah). This occurs even if I write the exact same SMTP address to the contacts field when updating.

    Somehow, EWS seems to be internally converting the SMTP address to an ExchangeLDn address. This is problematic for a number reasons. In particular, it seems to be breaking some of our other services that read from the exchange server and it makes it impossible to correctly display the email address without doing a very slow ResolveName call. Is there a way to stop EWS from doing this? A different service which uses Outlook Redemption has no problem properly writing an SMTP address but we're attempting to retire that service and the use of the Redemption API. I should also mention that this problem only occurs when updating contacts for internal users. External users always write the correct SMTP address.

    Thanks.

    Monday, July 2, 2012 2:15 PM

All replies

  • It depends on the way your updating the Email addresses if your using the Strongly typed object properties and the Email address your updating exists in the GAL then it will resolve it to the X500 address. What happens in the Background is the following five Extended properties get updated

    PidLidEmail1DisplayName (section 2.2.1.2.1)
    PidLidEmail1AddressType (section 2.2.1.2.2)
    PidLidEmail1EmailAddress (section 2.2.1.2.3)
    PidLidEmail1OriginalDisplayName (section 2.2.1.2.4)
    PidLidEmail1OriginalEntryId (section 2.2.1.2.5)

    The PidLidEmail1OriginalEntryId gets set to the One-OffEntryID format this is documented in http://msdn.microsoft.com/en-us/library/cc463907%28v=exchg.80%29.

    If you want to avoid this you would need to update all of these Extended properties manually. If you do this make sure you set the PidLidEmail1OriginalEntryId because the OneOfEntryID contains the Email address as well. I would suggest you look at the raw props manually using a Mapi like OutlookSpy or MFCMapi.

    Cheers
    Glen

    Tuesday, July 3, 2012 7:48 AM