none
EWS InternetMessageHeader RRS feed

  • Question

  • Can anyone guide me how to Set and read Internet message headers in Exchange 2007?

    I have tried setting it on my own but i am getting a error as "Invalid Property Set".

    My code is as follows

     

    email.InternetMessageHeaders = new InternetHeaderType[1];

    email.InternetMessageHeaders[0] = new InternetHeaderType();

    email.InternetMessageHeaders[0].HeaderName = "HeaderName";

    email.InternetMessageHeaders[0].Value = "Value";

     

    Monday, October 3, 2011 5:22 AM

Answers

  • If you want to set an X-header try using a Extended property instead eg

    // Start X-header Code
    
    PathToExtendedFieldType epExPath1 = new PathToExtendedFieldType();
    epExPath1.DistinguishedPropertySetId = DistinguishedPropertySetType.InternetHeaders;
    epExPath1.DistinguishedPropertySetIdSpecified = true;
    epExPath1.PropertyName = "x-myheader";
    epExPath1.PropertyType = MapiPropertyTypeType.String;
    
    ExtendedPropertyType xhXheaderProp = new ExtendedPropertyType();
    xhXheaderProp.ExtendedFieldURI = epExPath1;
    xhXheaderProp.Item = "blah";
    message.ExtendedProperty = new ExtendedPropertyType[] { xhXheaderProp };
    
    // End X-header Code
    
    // Add the message to the array of items to be created.
    createItemRequest.Items.Items = new ItemType[1]; 
    

    Cheers
    Glen

    • Marked as answer by Alok1282 Friday, October 7, 2011 6:03 AM
    Tuesday, October 4, 2011 1:31 AM

All replies

  • If you want to set an X-header try using a Extended property instead eg

    // Start X-header Code
    
    PathToExtendedFieldType epExPath1 = new PathToExtendedFieldType();
    epExPath1.DistinguishedPropertySetId = DistinguishedPropertySetType.InternetHeaders;
    epExPath1.DistinguishedPropertySetIdSpecified = true;
    epExPath1.PropertyName = "x-myheader";
    epExPath1.PropertyType = MapiPropertyTypeType.String;
    
    ExtendedPropertyType xhXheaderProp = new ExtendedPropertyType();
    xhXheaderProp.ExtendedFieldURI = epExPath1;
    xhXheaderProp.Item = "blah";
    message.ExtendedProperty = new ExtendedPropertyType[] { xhXheaderProp };
    
    // End X-header Code
    
    // Add the message to the array of items to be created.
    createItemRequest.Items.Items = new ItemType[1]; 
    

    Cheers
    Glen

    • Marked as answer by Alok1282 Friday, October 7, 2011 6:03 AM
    Tuesday, October 4, 2011 1:31 AM
  • Thanks a lot Glen
    Friday, October 7, 2011 6:12 AM