Platform SDK: Exchange Server

Reordering Rules

You may wish to re-order the sequence in which the rules fire. The rules are fired in a sequence defined in a property for each rule in the folder. Because the sequence numbers are not necessarily ordered in the folder using a single incremental value, (such as 1 or 10), there are a few steps you need to take to reorder the rules when using the Rules collection. Perform the following steps to reorder the rules.

  1. Create an instance of the Rules COM class.
  2. Bind the Rules object to a CDO Folder object using the IRules::Folder property. This means setting the object reference on a Folder object to this property.
  3. Set each Rule object's IRule::NewIndex property to some value relative to the others. The lowest NewIndex fires first.
  4. Once you have set all the new indexes, call the IRules::UpdateIndices method. The Rules object re-orders the IRule::Sequence properties for each Rule object, and then re-orders the IRule::Index property for each object in the collection. The Index property is always ordered with increments of 1.
  5. Call the IRules::Update method to commit the changes to the store.

The source code for the Rule COM component is available as a part of the Platform SDK samples download. Look in the DBMSG folder under Exchange.