How to read secondary SMTP email address of an email message using EWS managed API 1.1? RRS feed

  • General discussion

  • Hi,

    For legacy reasons on a mailbox we have two SMTP Email addresses say (primary) and (secondary). When I send emails to either of these addresses they arrive correctly to the mailbox, however I need to programmatically process the messages based on the To address i.e. if the mail is coming from primary email address do something and if it is sent to secondary email address do something else. 

    In exchange 2003 and older outlook versions the email addresses were correctly displayed i.e. secondary was always displayed as secondary and using webdav I was able to successfully get this address and do my processing. However, in the newer version the outlook always shows the primary SMTP email address and I can only see the email address in the Message Options Internet headers.

    So now my questions:

    1. what is the rationale behind this change i.e. why outlook is displaying it incorrectly? and

    2. how to programmatically read the Internet Headers on this message using EWS managed API 1.1 (more important)?

    Many thanks in advance.


    Monday, March 21, 2011 12:47 PM

All replies

  • 2. To read the internet headers in the managed api is pretty simple eg just use something like

       Folder inbox = Folder.Bind(service, WellKnownFolderName.Inbox);
       ItemView iv = new ItemView(2);
       FindItemsResults<Item> fit = inbox.FindItems(iv);
       foreach (Item itm in fit.Items)
        itm.Load(new PropertySet(BasePropertySet.IdOnly));
        foreach (InternetMessageHeader ihead in itm.InternetMessageHeaders)

    1. The Information about the actual email address a message is sent to is stored in the recipients collection which you can't access (outside of exportmessage) in EWS which i find frustrating as well.


    Tuesday, March 22, 2011 2:15 AM