Howto: Set multiple extended properties on a folder using raw XML for EWS with a POST

Hmmm, there are very few samples on setting multiple extended properties on folders using a POST to EWS... so, I thought I would blog one.

 

This sample can be used with:

     https://blogs.msdn.com/webdav_101/archive/2009/02/27/howto-post-xml-to-ews-using-exchangeservicebinding-credentials.aspx 

 

Note the following:

                The version is set.

                Each property being set is done under a separate SetFolderField node.

<?xml version="1.0" encoding="utf-8"?>

<soap:Envelope xmlns:soap="https://schemas.xmlsoap.org/soap/envelope/"

               xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types">

  <soap:Header>

      <t:RequestServerVersion Version="Exchange2007_SP1" />

  </soap:Header>

  <soap:Body>

    <UpdateFolder xmlns="https://schemas.microsoft.com/exchange/services/2006/messages"

                  xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types">

      <FolderChanges>

        <t:FolderChange>

          <t:FolderId Id="AAMkAGYyN2JmMDM5LThiMGQtNDg2NC1iOTJiLTcwNTAzYzA4MTJmZgAuAAAAAADQwmwDLXTRQqgtmPQzUYndAQAD87SOmtYKQJJgvwQj7+EZAITQgdTRAAA="

                ChangeKey="AQAAABYAAAAD87SOmtYKQJJgvwQj7+EZAITUPEsA"/>

          <t:Updates>

            <t:SetFolderField>

             <t:ExtendedFieldURI

                                                DistinguishedPropertySetId="PublicStrings"

                        PropertyName="TestA"

                        PropertyType="String"/>

                       <t:Folder>

              <t:ExtendedProperty>

                    <t:ExtendedFieldURI

                                                DistinguishedPropertySetId="PublicStrings"

                        PropertyName="TestA"

                        PropertyType="String"/>

                    <t:Value>testa</t:Value>

              </t:ExtendedProperty>

                </t:Folder>

            </t:SetFolderField>

            <t:SetFolderField>

             <t:ExtendedFieldURI

                PropertySetId="A29B59B5-4B75-57B7-A24F-23D6CD6C556C"

                        PropertyName="FolderB"

                        PropertyType="String"/>

                       <t:Folder>

              <t:ExtendedProperty>

                 <t:ExtendedFieldURI

                                PropertySetId="A29B59B5-4B75-57B7-A24F-23D6CD6C556C"

                        PropertyName="FolderB"

                        PropertyType="String"/>

                    <t:Value>TestColor</t:Value>

              </t:ExtendedProperty>

                </t:Folder>

            </t:SetFolderField>

            <t:SetFolderField>

             <t:ExtendedFieldURI

                PropertySetId="A29B59B5-4B75-57B7-A24F-23D6CD6C556C"

                        PropertyName="TestC"

                        PropertyType="Integer"/>

                       <t:Folder>

              <t:ExtendedProperty>

                    <t:ExtendedFieldURI

                                PropertySetId="A29B59B5-4B75-57B7-A24F-23D6CD6C556C"

                        PropertyName="TestC"

                        PropertyType="Integer"/>

                    <t:Value>3</t:Value>

              </t:ExtendedProperty>

                </t:Folder>

            </t:SetFolderField>

          </t:Updates>

        </t:FolderChange>

      </FolderChanges>

    </UpdateFolder>

  </soap:Body>

</soap:Envelope>