locked
Querying folder with X headers MS Exchange RRS feed

  • Question

  • I want to query my email folders for specific emails with custom headers that i've written on them. But it seems like the SOAP message that i am creating have some problems, it always retuns empty result set.

    I am sure that i have the email in the folder. If i query after removing the restrictions part, i can see the email in the query results. And if i connect to my account with let's say Thunderbird, then i can see the header is there.

    Thanks for reading.

    QUERY

    <?xml version="1.0"?>
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
      <soap:Header>
        <t:RequestServerVersion Version="Exchange2010"/>
      </soap:Header>
      <soap:Body>
        <FindItem xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" Traversal="Shallow">
          <ItemShape>
    <t:BaseShape>Default</t:BaseShape>
          </ItemShape>
          <m:Restriction>
    <t:IsEqualTo>
      <t:ExtendedFieldURI DistinguishedPropertySetId="InternetHeaders" PropertyName="X-My-Header" PropertyType="StringArray"/>
      <t:FieldURIOrConstant>
        <t:Constant Value="44A2F930-5E24-4F18-BC82-EC6B3A02E893"/>
      </t:FieldURIOrConstant>
    </t:IsEqualTo>
          </m:Restriction>
          <m:ParentFolderIds>
    <t:FolderId Id="AQMkADAwATM0MDAAMS1jMzg1LWZkMDMtMDACLTAwCgAuAAADlxvq+JrhgkiMcRwVFQDzo9MBANxoXUHEHORLhWKXuo92RaUAAAIBDwAAAA=="/>
          </m:ParentFolderIds>
        </FindItem>
      </soap:Body>
    </soap:Envelope>

    RESPONSE

    <?xml version="1.0" encoding="utf-8"?>
    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
      <s:Header>
        <h:ServerVersionInfo xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" MajorVersion="15" MinorVersion="20" MajorBuildNumber="178" MinorBuildNumber="14" Version="V2017_07_11"/>
      </s:Header>
      <s:Body>
        <m:FindItemResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
    <m:ResponseMessages>
      <m:FindItemResponseMessage ResponseClass="Success">
        <m:ResponseCode>NoError</m:ResponseCode>
        <m:RootFolder TotalItemsInView="0" IncludesLastItemInRange="true">
          <t:Items/>
        </m:RootFolder>
      </m:FindItemResponseMessage>
    </m:ResponseMessages>
        </m:FindItemResponse>
      </s:Body>
    </s:Envelope>

    Wednesday, November 1, 2017 3:25 PM