locked
How to get the X-MS-Exchange-Inbox-Rules-Loop header values via EWS? RRS feed

  • Question

  • I'm trying to obtain the X-MS-Exchange-Inbox-Rules-Loop header value(s), but find that it's not being returned as an ExtendedProperty despite the fact that it's clearly in the InternetMessageHeaders property.

    Is EWS treating this header specially, and I ought to be using some other built-in property of EmailMessage to access it?

    I'm testing using EWSEditor to request the header extended property.

    I also see the same behaviour if I try to get some other properties, such as X-MS-Exchange-Organization-SCL, but  other custom x-headers are accessible so I don't think I'm using EWSEditor incorrectly.

    Tuesday, January 26, 2016 4:43 PM

Answers

All replies

  • The best thing to do is if you want to process the Internet Message Headers is use the PR_TRANSPORT_MESSAGE_HEADERS extended property and then parse what you need out of this. This is explained a little better in https://msdn.microsoft.com/en-us/library/office/hh545614(v=exchg.140).aspx , even if the property you want was in the InternetMessageHeaders property you would need to still make a GetItem request to get the value but from a reliability perspective this will always work across any version of Exchange. You also have to take into account https://msdn.microsoft.com/en-us/library/office/dn596091(v=exchg.150).aspx when dealing with any Custom X-headers.

    Cheers
    Glen

    Wednesday, January 27, 2016 3:45 AM
  • Hi Glen,

    I have read that article - many times now, and I must admit that I find it a bit vague and insufficient to understand what's going on - or why. I guess I'm wondering what the underlying implementation is because it seems so inconsistent. I've not read any explanation for the behaviour I see - where the header values are in the InternetMessageHeaders property, but I can't retrieve them specifically via a Bind. Since I get the same behaviour when I try to get a standard header property, such as the In-Reply-To header value, I was wondering whether the header I wanted was exposed in a more direct way - in a similar way that there's the InReplyTo property.

    Wednesday, January 27, 2016 9:50 AM
  • For the benefit of anyone else in a similar situation of needing to prevent looping, we've spotted a named property "XLoop" that appears to contain the same information as the X-MS-Exchange-Inbox-Rules-Loop header value(s). It's a lot easier to access and eliminates the need to parse the values from the headers. Unfortunately, we can find no documentation of it, so we only have empirical evidence and no idea of its longevity in Outlook/Exchange, so if you do make use of it, beware and test thoroughly.

    ExtendedPropertyDefinition epdXLoop = new ExtendedPropertyDefinition( new Guid( "{41F28F13-83F4-4114-A584-EEDB5A6B0BFF}" ),
        "XLoop",
        MapiPropertyType.StringArray );
    
    // Access it after requesting it in a Bind operation:
    EmailMessage Msg = EmailMessage.Bind( Service, MsgId,
                           new PropertySet( epdXLoop ) );
    
    object objXLoop;
    Msg.TryGetProperty( epdXLoop, out objXLoop );
    
    The property value is a string[], where each element is the email address.

    Monday, February 1, 2016 4:13 PM