RDORule object

 

RDORule object represents a rule defined in the parent Exchange mailbox.

 

Returned by:

RDORules.Create, RDORules.Item

 

The example below creates a new rule that marks all incoming messages as read

set Session = CreateObject("Redemption.RDOSession")
Session.Logon
set Rules = Session.Stores.DefaultStore.Rules 'will raise an error if not an Exchange store
set Rule = Rules.Create("Mark As Read Rule")
set Action = Rule.Actions.MarkAsRead 'a predefined action which might not yet exist
Action.Enabled = true
Rule.Save

 

Properties

Methods

 


Derived from: IDispatch


Properties


Actions

RDORuleActions, read-only. Returns the collection representing the available actions for the rule.

 

See the example above

Conditions

Reserved for future use. To set the rule conditions and exceptions, use the SetRawConditionsKind method (see below). To read the existing conditions and exceptions, use the RawConditions property (see below).

 

 

ConditionsAsSQL

String, read/write. Allows to retrieve or set the rule conditions as a standard SQL style string.

 

The properties specified in the SQL query must either use the Outlook Object Model (or RDO) property name (e.g. Subject, Email1Address) or a DASL style property name (e.g. "http://schemas.microsoft.com/mapi/proptag/0x0037001E", "http://schemas.microsoft.com/mapi/id/{00062004-0000-0000-C000-000000000046}/8083001E")

When a DASL property name is used, it must be enclosed in double quotes.

Use OutlookSpy to figure out the DASL property names - select an item in Outlook, click IMessage button on the OutlookSpy toolbar, select the property, see the "DASL" edit box on he right hand side of the window.

 

set Session = CreateObject("Redemption.RDOSession")
Session.Logon
set Store = Session.Stores.DefaultStore
set Inbox = Store.GetDefaultFolder(olFolderInbox)
on error resume next
err.clear
set SubFolder = Inbox.Folders("Urgent messages from dmitry")
if (err.Number <> 0) or (SubFolder Is Nothing) Then
    set SubFolder = Inbox.Folders.Add("Urgent messages from dmitry")
End If
set Rules = Store.Rules
set Rule = Rules.Create("Copy to subfolder if from dmitry@dimastr.com")
Rule.ConditionsAsSQL = "(SenderEmailAddress = 'dmitry@dimastr.com') and (Subject like '%urgent%')"
set Action = Rule.Actions.CopyToFolder
Action.Folder = SubFolder
Action.Enabled = true
Rule.Enabled = true
Rule.Save

 

Enabled

Boolean, read/write. True if the rule is enabled, false otherwise.

 

 

Exceptions

Reserved for future use. To set the rule conditions and exceptions, use the SetRawConditionsKind method (see below). To read the existing conditions and exceptions, use the RawConditions property (see below).

 

 

ExecutionOrder

Integer, read/write. Indicates the order of execution of the rule among the rules in the parent RDORules collection.

 

 

KeepOOFHistory

Boolean, read/write. Applicable only when OnlyWhenOOF property is set to true.

If true, the rule fires only once for each sender. This way the action such as an OOF reply will be sent only once per sender.

The OOF history is reset when OOF is reset back to false (RDOExchangeMailboxStore.OutOfOfficeAssistant.OutOfOffice = false)

 

 

Name:

String, read/write. Returns or sets the name of the rule.

 

set Session = CreateObject("Redemption.RDOSession")
Session.Logon
set Rules = Session.Stores.DefaultStore.Rules 'will raise an error if not an Exchange store
for each Rule in Rules
  Debug.Print Rule.Name
next

 

OnlyWhenOOF

 

'Create a rule for the "natalia" mailbox that will redirect all messages
' to the "dmitry" mailbox if "natalia" is OOF

set Session = CreateObject("Redemption.RDOSession")
Session.Logon
set Store = Session.Stores.GetSharedMailbox("natalia")
set Inbox = Store.GetDefaultFolder(olFolderInbox)
set Rules = Store.Rules
set Rule = Rules.Create("Redirect when OOF")
set Action = Rule.Actions.Redirect
set Recip = Action.Recipients.Add("dmitry")
Recip.Resolve
Action.Enabled = true
Rule.Enabled = true
Rule.OnlyWhenOOF = true
Rule.Save

 

Provider

String, read/write. Returns or sets the name of the rule provider, such as "RuleOrganizer". Corresponds to PR_RULE_NAME in MAPI.

 

 

RawConditions

Returns Restriction object representing the restriction determining when and if the rule fires. If NULL, the rule will fire on each incoming message.

To set the conditions for a new rule or modify conditions for an existing rule, use the SetRawConditionsKind method (see below)

 

See SetRawConditionsKind below

StopProcessingOtherRules

Boolean, read/write. When set to true, if the rule conditions are met and the rule is executed, other rules with the ExecutionOrder property higher than that for this rule will not be executed. Useful if the rule moves or deletes the message.

 

 


Methods


Delete

Deletes the rule

 

 

Save

Saves the rule

 

 

SetRawConditionsKind(Kind)

Set the rule conditions for the rule. Returns Restriction object representing the restriction determining when and if the rule fires.

 

You can also set the conditions using the ConditionsAsSQL property (see above).

 

Kind - one of the RestrictionKind enums:

 

RES_AND = 0
RES_BITMASK = 6
RES_COMPAREPROPS = 5
RES_CONTENT = 3
RES_EXIST = 8
RES_NOT = 2
RES_OR = 1
RES_PROPERTY = 4
RES_SIZE = 7
RES_SUBRESTRICTION = 9
RES_COMMENT = 10

'Example 1

'Create a rule for the "natalia" mailbox that will redirect all messages
' to the "dmitry" mailbox if the MIME message headers contain "x-test-header"
'Constant definitions, don't need these if Redemption is added to the project references.

RES_CONTENT = 3
FL_SUBSTRING = 1
FL_IGNORECASE = &H10000
PR_TRANSPORT_MESSAGE_HEADERS = &H007D001E
'create the rule in natalia's mailbox
set Session = CreateObject("Redemption.RDOSession")
Session.Logon
set Store = Session.Stores.GetSharedMailbox("natalia")
set Rules = Store.Rules
set Rule = Rules.Create("Redirect to dmitry if header contains 'x-test-header'")
'set the action
set Action = Rule.Actions.Redirect
set Recip = Action.Recipients.Add("dmitry")
Recip.Resolve
Action.Enabled = true
'set the conditions:
set Restriction = Rule.SetRawConditionsKind(RES_CONTENT)
Restriction.ulFuzzyLevel = FL_SUBSTRING or FL_IGNORECASE
Restriction.ulPropTag = PR_TRANSPORT_MESSAGE_HEADERS
Restriction.lpProp = "x-test-header"

'enable and save the rule
Rule.Enabled = true
Rule.Save

 

'Example 2

'Create a rule for the "natalia" mailbox that will redirect all messages
'from the outside of the Exchange domain (sender address type = "SMTP")
'between October 1, 2007 and November 1, 2007 to the "dmitry"
'mailbox if "natalia" is OOF
'Constant definitions, don't need these if Redemption is added to the project references.

RES_AND = 0
RES_PROPERTY = 4
RES_CONTENT = 3
RELOP_EQ = 4
RELOP_GE = 3
RELOP_LT = 0
FL_FULLSTRING = 0
FL_IGNORECASE = &H10000
PR_MESSAGE_DELIVERY_TIME = &H0E060040
PR_SENDER_ADDRTYPE = &H0C1E001E
'create the rule
set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set Store = Session.Stores.GetSharedMailbox("natalia")
set Inbox = Store.GetDefaultFolder(olFolderInbox)
set Rules = Store.Rules
set Rule = Rules.Create("Redirect when OOF in October 2006")
'set the action
set Action = Rule.Actions.Redirect
set Recip = Action.Recipients.Add("dmitry")
Recip.Resolve
Action.Enabled = true
'set the conditions:
'(ReceivedTime >= 10/1/2007) AND (ReceivedTime <= 11/1/2007) AND (SenderAddressType = "SMTP")
set Conditions = Rule.SetRawConditionsKind(RES_AND)
set Restriction= Conditions.Add(RES_PROPERTY)
Restriction.relop = RELOP_GE
Restriction.ulPropTag = PR_MESSAGE_DELIVERY_TIME
Restriction.lpProp = #10/01/2007#
set Restriction = Conditions.Add(RES_PROPERTY)
Restriction.relop = RELOP_LT
Restriction.ulPropTag = PR_MESSAGE_DELIVERY_TIME
Restriction.lpProp = #11/01/2007#
set Restriction = Conditions.Add(RES_CONTENT)
Restriction.ulFuzzyLevel = FL_FULLSTRING or FL_IGNORECASE
Restriction.ulPropTag = PR_SENDER_ADDRTYPE
Restriction.lpProp = "SMTP"

'enable and save the rule
Rule.Enabled = true
Rule.OnlyWhenOOF = true
Rule.Save