none
Exchange Web Service - CreateAttachment to Attach an Existing Item in a Folder RRS feed

  • Question

  • Hi,

    I would like to know if someone could help me understand how to create an EWS attachment for a message where the attachment is an existing email message that resides in a folder in the user's mailbox on the Exchange server. I've seen lots of examples that seem to work if the attachment message is specified as a 'New' message in the CreateAttachment request (i.e.: http://qa.social.technet.microsoft.com/Forums/en-US/exchangesvrdevelopment/thread/386cb660-03c5-46ea-882a-5d2b1a3ba4be), but I have not found an example that I can reference if I want to attach an existing message in a folder.  Think of it like a forward - except I want to create new message and attach the message that I'm forwarding.

    Here's what I am trying to do:

    1. Retrieved the Id and ChangeKey for a message that I want to attach

    2. Create a new draft message

    3. Create a new attachment referencing the Id and ChangeKey from step 1

    4. Send the draft message

    I am currently stuck at step 3 with the following error:

             <m:ResponseMessages>
                <m:CreateAttachmentResponseMessage 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:ItemId"/>
                   </m:MessageXml>
                   <m:Attachments/>
                </m:CreateAttachmentResponseMessage>
             </m:ResponseMessages>

    A sample of the CreateAttachment Xml I am using in the request is as follows (long attributes truncated for readability):

    <CreateAttachment xmlns='http://schemas.microsoft.com/exchange/services/2006/messages' xmlns:t='http://schemas.microsoft.com/exchange/services/2006/types'>
       <ParentItemId Id="AAAk ... B7bBBwAAA=" ChangeKey="CQ ... B7bgGp"/>
       <Attachments>
          <t:ItemAttachment>
             <t:Name>My Email Attachment</t:Name>
             <t:Message>
                <t:ItemId Id="AAAkAFR ... yQDAAA=" ChangeKey="CQAA ... ANicg=="/>
                <t:ParentFolderId Id="AAAkAF ... VAAA=" ChangeKey="AQAAAA=="/>
             </t:Message>
          </t:ItemAttachment>
       </Attachments>
    </CreateAttachment>

    I think that all of the above steps are correct as I have successfully completed step 3 if I do a file attachment.  However, I really want to attach an existing email (one that was sent to me ... not one that I create).

    I tried posting this on the Exchange Server 2010 forum, but they suggested that this would be a better forum to determine exactly how to accomplish this task.

    I would very much appreciate any assistance that can be provided.

    Thanks, Tyler

    Thursday, March 14, 2013 10:13 PM