I am getting the below error when I try to forward an email using EWS create operation.
The request failed schema validation: The element 'ForwardItem' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types' has invalid child element 'Subject' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types'. List of possible elements expected: 'CcRecipients, BccRecipients, IsReadReceiptRequested, IsDeliveryReceiptRequested, From, ReferenceItemId, NewBodyContent' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types'
As per this link 'Subject' is a valid element under 'ForwardItem'. I am using Exchange2013. Any thoughts on what I am doing wrong? The same request works with O365.
SOAP Request
<?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: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>
<RequestServerVersion Version="Exchange2013"
xmlns="http://schemas.microsoft.com/exchange/services/2006/types"
soap:mustUnderstand="0" />
</soap:Header>
<soap:Body>
<m:CreateItem MessageDisposition="SendAndSaveCopy">
<m:Items>
<t:ForwardItem>
<t:ToRecipients>
<t:Mailbox>
<t:EmailAddress>admin@test.onmicrosoft.com</t:EmailAddress>
</t:Mailbox>
</t:ToRecipients>
<t:Subject>Email Submitted</t:Subject>
<t:ReferenceItemId Id="AQMkADJmMTI3Njk1LWZjOWItNDM2Os.."
ChangeKey="CQAAABYAAAAmV1x/D6z5Q7lUEv1+KENlAAAAAACV"/>
<t:NewBodyContent BodyType="Text"></t:NewBodyContent>
</t:ForwardItem>
</m:Items>
</m:CreateItem>
</soap:Body>
</soap:Envelope>
ForwardItem
requires elements to be in the order they are defined in the schema -
ForwardItem
Try moving the Subject
above ToRecipients
:
<t:ForwardItem>
<t:Subject>Email Submitted</t:Subject>
<t:ToRecipients>
<t:Mailbox>
<t:EmailAddress>admin@test.onmicrosoft.com</t:EmailAddress>
</t:Mailbox>
</t:ToRecipients>
<t:ReferenceItemId Id="AQMkADJmMTI3Njk1LWZjOWItNDM2Os.."
ChangeKey="CQAAABYAAAAmV1x/D6z5Q7lUEv1+KENlAAAAAACV"/>
<t:NewBodyContent BodyType="Text"></t:NewBodyContent>