4.2 SetInboxRule

The following is an example of an UpdateInboxRules operation that updates an Inbox rule (2).

The client constructs the request XML and sends it to the server. The SetRuleOperation complex type contains the rule (2) to be updated. This example updates the existing identified rule (2), which will search for a subject string "This is Junk". The FolderId attribute has 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_SP1" />
   </soap:Header>
   <soap:Body>
     <m:UpdateInboxRules>
       <m:RemoveOutlookRuleBlob>true</m:RemoveOutlookRuleBlob>
       <m:Operations>
         <t:SetRuleOperation>
           <t:Rule>
             <t:RuleId>dCsAAABjzwQ=</t:RuleId>
             <t:DisplayName>MoveInterestingToJunk</t:DisplayName>
             <t:Priority>1</t:Priority>
             <t:IsEnabled>true</t:IsEnabled>
             <t:IsInError>false</t:IsInError>
             <t:Conditions>
               <t:ContainsSubjectStrings>
                 <t:String>This is Junk</t:String>
               </t:ContainsSubjectStrings>
             </t:Conditions>
             <t:Exceptions />
             <t:Actions>
               <t:MoveToFolder>
                 <t:FolderId Id="AAMkAGYzZjZm=" ChangeKey="AQAAAA==" />
               </t:MoveToFolder>
             </t:Actions>
           </t:Rule>
         </t:SetRuleOperation>
       </m:Operations>
     </m:UpdateInboxRules>
   </soap:Body>
 </soap:Envelope>
  

The server constructs the response XML and sends it to the client.

 <?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="139" 
         MinorBuildNumber="0" 
         Version="Exchange2010_SP1" 
         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">
     <UpdateInboxRulesResponse ResponseClass="Success"
         xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">
       <ResponseCode>NoError</ResponseCode>
     </UpdateInboxRulesResponse>
   </s:Body>
 </s:Envelope>
  
Show: