EWS Managed API when using ExtendedPropertyDefinition displays property in header in lower case? How do we display in Upper case ? RRS feed

  • Question

  • ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
                    service.Credentials = new WebCredentials("hghgh", "hghg","yuu");

                    // Create the e-mail message, set its properties, and send it to, saving a copy to the Sent Items folder.
                    EmailMessage message = new EmailMessage(service);
                    message.Subject = "Subject";
                    message.Body = "Body text comes here";


    ExtendedPropertyDefinition cUID = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.InternetHeaders, "CITUID", MapiPropertyType.String);
                    message.SetExtendedProperty(cUID, "ID-12345678");


    Result seen in the header of the message in MS Outlook:


    cituid:ID-12345678 ----> this is property appearing as header in MS Outlook headers

    As you know above I have created an extended property above that will appear as a header

    Question : Is there a way by which the header can be set to display in UPPER CASE. As there is another 3rd party product that cannot parse the header as it appears in lower case.

    Is there a way I can use a 'X-somthing' to appear as a header. I have heard that Exchange Server does not like 'X-..' being used as custom headers.

    Wednesday, December 1, 2010 5:04 AM

All replies

  • To

    David Claux

    Program Manager



    Hi David Claux

    Since you and your team were  responsible for designing the EWS Managed API library.

    I was wondering if you could answer the above question?

    Wednesday, December 15, 2010 11:38 PM
  • You can create a custom header into Internet Message Headers by ManagedAPI 1.1 as folowing. But it is workaround and our Exchange Server version is 2010 sp1.

    Folder inbox = Folder.Bind(service, WellKnownFolderName.Inbox);
    FindItemsResults<Item> result = inbox.FindItems(view);
    foreach (Item item in result)
        ExtendedPropertyDefinition transportMsgHdr = new ExtendedPropertyDefinition(0x007D, MapiPropertyType.String);
        item.Load(new PropertySet((PropertyDefinitionBase)transportMsgHdr));

        using (StringReader reader = new StringReader(Convert.ToString(property.Value)))
            int lineNo = 0;
            string line;
            string input = string.Empty;
            bool exists = false;
            while ((line = reader.ReadLine()) != null)
                if (line.ToLower().StartsWith("x-mtr")) {
                    exists = true;
                    input = line;
            if(exists) property.Value.ToString().Replace(input, "\nX-CUSTOM-HEADER: VALUE STRING");
            else property.Value += "\nX-CUSTOM-HEADER: VALUE STRING";



    • Edited by mark8236 Wednesday, November 23, 2011 8:11 AM
    Wednesday, November 23, 2011 8:07 AM