Modifying Rules

To modify a rule, find the rule you want changed, save and edit its contents, delete it, and insert the new rule in the old rule’s position in the rule table.

    To modify a rule
  1. Retrieve an interface pointer to the rule object using HrFolderRulesOpen.
  2. Find the rule you want to modify. First, use the rule object’s IExchangeFolderRules::HrSeek method to seek to the beginning of the rule table.
  3. Within a loop, call the rule object’s IExchangeFolderRules::HrGet method to step through the rule table until you find the rule you want to modify.
  4. Save the information of the rule to be modified. You can do this as a part of the loop described in step 3 because HrGet returns all the information of the rule, including pointers to an SRestriction structure and an ACTIONS structure. The SRestriction structure contains the rule’s conditions. The ACTIONS structure contains the rule’s actions.
  5. Modify the saved information to reflect the rule changes you want to make. You will be modifying data of a variety of types.
  6. Back the cursor up by 1 by calling the IExchangeFolderRules::HrTell method (to determine the absolute position in the rule table) and the IExchangeFolderRules::HrSeek method (to move to the next lower position).
  7. Delete the rule you want to modify by calling IExchangeFolderRules::HrDelete. For HrDelete, the cursor is unchanged. If you delete a rule and then insert a rule, the new rule goes back in the same position.
  8. Create a new rule with the IExchangeFolderRules::HrInsert method. This method inserts the rule into the set of rules for the folder.

To review these methods, see the \BKOFFICE\SAMPLES\EXCHANGE\LIBSRC\RULECLS\RULECLSI.CPP source file. For examples of rule deletion and rule insertion, see the DoDelete function and the DoInsert function in the \BKOFFICE\SAMPLES\EXCHANGE\RULEEDIT\RULEEDIT.CPP file.