Extended property in EWS

928 Views Asked by At

I am interacting with exchange to extract emails having particular extended property. I am able to fetch email that I have sent with newly created extended properties, but when I reply to the emails, these properties are not preserved..Is this normal behavior? Is there anyway to work around it?

The code I am using to send and fetch email for now is as below

To send email with extended property

`<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
      xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
      xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <t:RequestServerVersion Version="Exchange2010" />
  </soap:Header>
  <soap:Body>
    <m:CreateItem MessageDisposition="SendAndSaveCopy">
      <m:SavedItemFolderId>
        <t:DistinguishedFolderId Id="sentitems" />
      </m:SavedItemFolderId>
      <m:Items>
        <t:Message>
          <t:Subject>Greetings</t:Subject>
          <t:Body BodyType="Text">Message with extended property attached</t:Body>
          <t:ExtendedProperty>
            <t:ExtendedFieldURI PropertySetId="c11ff724-aa03-4555-9952-8fa248a11c3e"
              PropertyName="extended_property_name" PropertyType="String" />
            <t:Value>NEWVALUE</t:Value>
          </t:ExtendedProperty>
          <t:ToRecipients>
            <t:Mailbox>
              <t:EmailAddress>[email protected]</t:EmailAddress>
            </t:Mailbox>
          </t:ToRecipients>
        </t:Message>
      </m:Items>
    </m:CreateItem>
  </soap:Body>
</soap:Envelope>`

Fetching email with extended property

`<?xml version="1.0" encoding="UTF-8" ?>
<soapenv:Envelope
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:typ="http://schemas.microsoft.com/exchange/services/2006/types"
    xmlns:mes="http://schemas.microsoft.com/exchange/services/2006/messages">
    <soapenv:Header>
        <typ:RequestServerVersion Version="Exchange2007_SP1"/>
    </soapenv:Header>
    <soapenv:Body>
        <mes:FindItem Traversal="Shallow">
            <mes:ItemShape>
                <typ:BaseShape>Default</typ:BaseShape>
                <typ:IncludeMimeContent>false</typ:IncludeMimeContent>
                <typ:BodyType>Best</typ:BodyType>
            </mes:ItemShape>
            <mes:IndexedPageItemView MaxEntriesReturned="10" Offset="0" BasePoint="Beginning"/>
         <mes:GroupBy Order="Ascending">
            <typ:FieldURI FieldURI="item:DateTimeReceived" />         
            <typ:AggregateOn Aggregate="Maximum">
               <typ:FieldURI FieldURI="item:ItemId"/> 
            </typ:AggregateOn>
         </mes:GroupBy> 
            <mes:Restriction>
                    <typ:IsEqualTo>
                        <typ:ExtendedFieldURI PropertySetId="c11ff724-aa03-4555-9952-8fa248a11c3e" PropertyName="extended_property_name" PropertyType="String" />
                        <typ:FieldURIOrConstant>
                            <typ:Constant Value="NEWVALUE" />
                        </typ:FieldURIOrConstant>
                    </typ:IsEqualTo>
            </mes:Restriction>
            <mes:ParentFolderIds>
                <!--You have a CHOICE of the next 2 items at this level-->
                <typ:FolderId Id="[Process.Variables.Completed Id]" 
            ChangeKey="[Process.Variables.Completed ChangeKey]"/>
            </mes:ParentFolderIds>
        </mes:FindItem>
    </soapenv:Body>
</soapenv:Envelope>`

Any Help will be greatly appreciated!

Thanks

1

There are 1 best solutions below

0
On BEST ANSWER

Yes that is normal the extended properties your setting are for the message your sending, the response is a brand new message and won't contain any custom properties you have set (this would actually be more of a problem if it did). If your trying to correlate response and reply then you should look at the InReplyto,Referances or ConversationId eg http://blog.mailgun.com/tracking-replies-in-mailgun-or-any-other-email/

cheers Glen