When replying to an email the send request happens asynchronously which means that the message id is not returned in the response.
According to Microsoft the solution is to add an ExtendedProperty
to the message to act as a unique id which can later be used to find the newly sent email using a Restriction
in FindItem
.
I have succeeded in doing this when sending a regular email, as follows:
<ns2:CreateItem MessageDisposition="SendAndSaveCopy">
<ns2:SavedItemFolderId>
<ns1:DistinguishedFolderId Id="sentitems"/>
</ns2:SavedItemFolderId>
<ns2:Items>
<ns1:Message>
<ns1:ItemClass>IPM.Note</ns1:ItemClass>
<ns1:Subject>Test create item</ns1:Subject>
<ns1:Body BodyType="Text">And here is the body</ns1:Body>
<ns1:ExtendedProperty>
<ns1:ExtendedFieldURI
PropertyName="CustomId"
PropertySetId="SOME SET ID"
PropertyType="String"
/>
<ns1:Value>UNIQUE ID</ns1:Value>
</ns1:ExtendedProperty>
<ns1:ToRecipients>
<ns1:Mailbox>
<ns1:EmailAddress>my@email.com</ns1:EmailAddress>
</ns1:Mailbox>
</ns1:ToRecipients>
</ns1:Message>
</ns2:Items>
</ns2:CreateItem>
The problem is that when trying to add the ExtendedProperty
to a Message
contained in ReplyAllToItem
, the field is not included in the request.
<ns2:CreateItem MessageDisposition="SaveOnly">
<ns2:SavedItemFolderId>
<ns1:DistinguishedFolderId Id="sentitems"/>
</ns2:SavedItemFolderId>
<ns2:Items>
<ns1:ReplyAllToItem>
<ns1:Subject>Subject</ns1:Subject>
<ns1:ToRecipients>
<ns1:Mailbox>
<ns1:EmailAddress>my@email.com</ns1:EmailAddress>
</ns1:Mailbox>
</ns1:ToRecipients>
<ns1:CcRecipients/>
<ns1:ReferenceItemId ChangeKey="CQ=" Id="AA="/>
<ns1:NewBodyContent BodyType="HTML">Body</ns1:NewBodyContent>
</ns1:ReplyAllToItem>
</ns2:Items>
</ns2:CreateItem>
By the way I am using php-ews to build the requests.