UpdateItem to add new InternetHeaders that are available along with X-headers

Pedro Torres 1 Reputation point
2022-02-25T10:26:03.127+00:00

I am trying to add an additional Header to an email using an Outlook addin (copying an email and sending that copy to a server to process the mail based on the received Headers), but if I include it in the UpdateItem request, as an ExtendedProperty, the received email has this as an extended property but not as a regular InternetHeader, like the X-headers. How could I add this Custom_Header to the mail?

I tried Appending the header directly in the InterMessageHeaders property, but that doesnt work as that function is only available for certain other fields.

'<?xml version="1.0" encoding="utf-8"?>' +
            "<soap:Envelope" +
            '  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' +
            '  xmlns:xsd="http://www.w3.org/2001/XMLSchema"' +
            '  xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"' +
            '  xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"> ' +
            "  <soap:Header>" +
            '  <t:RequestServerVersion Version="Exchange2013" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" soap:mustUnderstand="0"/>' +
            "  </soap:Header>" +
            "  <soap:Body>" +
            '    <UpdateItem MessageDisposition="SaveOnly" ConflictResolution="AutoResolve"' +
            '                xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">' +
            "      <ItemChanges>" +
            "      <t:ItemChange>" +
            '        <t:ItemId Id="' +
            itemId +
            '" ChangeKey="' +
            changeKey +
            '"/>' +
            "        <t:Updates>" +
            "          <t:SetItemField>" +
            '            <t:ExtendedFieldURI DistinguishedPropertySetId="InternetHeaders" PropertyName="Custom_Header" PropertyType="Integer"/>' +
            "            <t:Message>" +
            "              <t:ExtendedProperty>" +
            '                <t:ExtendedFieldURI DistinguishedPropertySetId="InternetHeaders" PropertyName="Custom_Header" PropertyType="Integer"/>' +
            "                <t:Value>42</t:Value>" +
            "              </t:ExtendedProperty>" +
            "            </t:Message>" +
            "          </t:SetItemField>" +
            "        </t:Updates>" +
            "        </t:ItemChange>" +
            "      </ItemChanges>" +
            "    </UpdateItem>" +
            "  </soap:Body>" +
            "</soap:Envelope>";
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,576 questions
Exchange Server Development
Exchange Server Development
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Development: The process of researching, productizing, and refining new or existing technologies.
516 questions
Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
7,387 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Michel de Rooij 1,536 Reputation points MVP
    2022-03-08T13:13:33.963+00:00

    InternetMessageHeaders collection will only return some of the headers and is read-only; to retrieve the entire thing, get the MAPI property PR_TRANSPORT_MESSAGE_HEADERS (0x007D).
    Here's an (old) article that might get you going: link

    0 comments No comments