4.2 Get Message Example

The following is an example of a GetItem operation that gets a message. This example gets a message from the server store. The message is already identified with its ItemId Id and ChangeKey attributes.

The client constructs the request XML and sends it to the server. Note that the ItemId Id and ChangeKey attributes have been shortened to preserve readability.

   <?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:GetItem>
         <m:ItemShape>
           <t:BaseShape>IdOnly</t:BaseShape>
           <t:AdditionalProperties>
             <t:FieldURI FieldURI="item:Body" />
           </t:AdditionalProperties>
         </m:ItemShape>
         <m:ItemIds>
           <t:ItemId Id="AAMkAGY4YzQw" ChangeKey="CQAAABYAAA " />
         </m:ItemIds>
       </m:GetItem>
     </soap:Body>
   </soap:Envelope>

The server constructs the response XML and sends it to the client. Note that the ItemId Id and ChangeKey attributes have been shortened to preserve readability.

   <?xml version="1.0" encoding="utf-8"?>
   <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
     <s:Header>
       <h:ServerVersionInfo MajorVersion="14" 
           MinorVersion="1" 
           MajorBuildNumber="63" 
           MinorBuildNumber="0" 
           Version="Exchange2010" 
           xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" 
           xmlns="http://schemas.microsoft.com/exchange/services/2006/types" 
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
           xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
     </s:Header>
     <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
         xmlns:xsd="http://www.w3.org/2001/XMLSchema">
       <m:GetItemResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" 
           xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
         <m:ResponseMessages>
           <m:GetItemResponseMessage ResponseClass="Success">
             <m:ResponseCode>NoError</m:ResponseCode>
             <m:Items>
               <t:Message>
                 <t:ItemId Id="AAMkAGY4YzQw" ChangeKey="CQAAABYAAA " />
                 <t:Body BodyType="HTML">&lt;meta http-equiv="Content-Type" content="text/html; 
                     charset=utf-8"&gt;The merger is finalized.</t:Body>
               </t:Message>
             </m:Items>
           </m:GetItemResponseMessage>
         </m:ResponseMessages>
       </m:GetItemResponse>
     </s:Body>
   </s:Envelope>