2

I meet a trouble when using EWS javascript API to send email with CreateItem operation.

<?xml version="1.0" encoding="utf-8"?>
<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>
    <m:CreateItem MessageDisposition="SendAndSaveCopy">
      <m:SavedItemFolderId>
        <t:DistinguishedFolderId Id="drafts" />
      </m:SavedItemFolderId>
      <m:Items>
        <t:Message>
          <t:Subject>Test</t:Subject>
          <t:Body BodyType="Text">
            Test
          </t:Body>
          <t:Attachments>
            <t:ItemAttachment>
              <t:Name>Attached Message Item</t:Name>
              <t:Message>
                <t:Subject></t:Subject>
                <t:Body BodyType="Text">Test</t:Body>
                <t:ToRecipients>
                  <t:Mailbox>
                    <t:EmailAddress>sunt@domain.com</t:EmailAddress>
                  </t:Mailbox>
                </t:ToRecipients>
              </t:Message>
            </t:ItemAttachment>
          </t:Attachments>
          <t:ToRecipients>
            <t:Mailbox>
              <t:EmailAddress>sunt@domain.com</t:EmailAddress>
            </t:Mailbox>
          </t:ToRecipients>
        </t:Message>
      </m:Items>
    </m:CreateItem>
  </soap:Body>
</soap:Envelope>

And after executing the service request, the response status is succeeded, but the response value indicates there's an error:

<?xml version="1.0" encoding="utf-8"?>
    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
      <s:Header>
        <h:ServerVersionInfo MajorVersion="15" MinorVersion="0" MajorBuildNumber="847" MinorBuildNumber="40" Version="V2_8" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns="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"/>
      </s:Header>
      <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <m:CreateItemResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
          <m:ResponseMessages>
            <m:CreateItemResponseMessage ResponseClass="Error">
              <m:MessageText>Set action is invalid for property.</m:MessageText>
              <m:ResponseCode>ErrorInvalidPropertySet</m:ResponseCode>
              <m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
              <m:MessageXml>
                <t:FieldURI FieldURI="item:Attachments"/>
              </m:MessageXml>
              <m:Items/>
            </m:CreateItemResponseMessage>
          </m:ResponseMessages>
        </m:CreateItemResponse>
      </s:Body>
    </s:Envelope>

Can't the CreateItem operation execute with attachment? Or how to succeed with it?

will
  • 21
  • 1
  • I have no time to go over your XML in detail, but have you looked at [How to: Add attachments by using EWS in Exchange](https://msdn.microsoft.com/en-us/library/office/dn726694%28v=exchg.150%29.aspx), specifically [Create an email with file and item attachments by using EWS](https://msdn.microsoft.com/en-us/library/office/dn726694%28v=exchg.150%29.aspx#bk_createattachews) on that page? – Jan Doggen Aug 06 '15 at 08:47
  • Thanks, Jan. I've dealed this problem as follow: use the CreateItem operation still, but change the MessageDisposition to 'SaveOnly', and then use SendItem operation to send the created item. I don't know why, but it works... – will Aug 07 '15 at 09:39
  • Could be related: http://stackoverflow.com/questions/6250796/ews-php-sending-email-with-attachment – Jan Doggen Aug 07 '15 at 10:07

0 Answers0