RDOSearchCriteria object

 

RDOSearchCriteria object represents a restriction used by a MAPI search folder (RDOSearchFolder object). All changes made to this object are only applied after RDOSearchFolder.Start method is called.

 

Returned by:

RDOSearchFolder.SearchCriteria

 

The example below logs to the default MAPI session and creates a new search folder that contains messages with the "test" substring in the subject property. The search is performed in the Inbox and Sent Items folders.

Note that you will need to wait until RDOSearchFolder.IsRebuild property (see below) becomes false, meaning that Outlook finished searching through the specified folders.

Also note that the newly created folder will not be displayed as one of the "Search Folders" subfolders in Outlook 2003. Use RDOSearches and RDOSearch objects for that.

RES_CONTENT = 3
FL_SUBSTRING = 1
FL_IGNORECASE = &H10000
PR_SUBJECT = &H0037001E
'create new search folder
set Session = CreateObject("Redemption.RDOSession")
Session.Logon
set DefaultStore = Session.Stores.DefaultStore
set SearchRootFolder = DefaultStore.SearchRootFolder
set NewSearchFolder = SearchRootFolder.Folders.AddSearchFolder("Test Redemption Search Folder")
'set the restriction to search for message with the word "test" in the subject line
set Restriction = NewSearchFolder.SearchCriteria.SetKind(RES_CONTENT)
Restriction.ulFuzzyLevel = FL_SUBSTRING or FL_IGNORECASE
Restriction.ulPropTag = PR_SUBJECT
Restriction.lpProp = "test"

'specify that the search should be performed in the Inbox and Sent Items folders
NewSearchFolder.SearchContainers.Add(DefaultStore.GetDefaultFolder(olFolderInbox))
NewSearchFolder.SearchContainers.Add(DefaultStore.GetDefaultFolder(olFolderSentMail))
'specify the search flags
NewSearchFolder.IsRecursiveSearch = false
NewSearchFolder.IsForegroundSearch = false
'we are all set: set the search parameters and let the fun begin!
NewSearchFolder.Start

 

The example below creates the same search folder as the one above but uses AsSQL property instead of SetKind.

'create new search folder
set Session = CreateObject("Redemption.RDOSession")
Session.Logon
set DefaultStore = Session.Stores.DefaultStore
set SearchRootFolder = DefaultStore.SearchRootFolder
set NewSearchFolder = SearchRootFolder.Folders.AddSearchFolder("Test Redemption Search Folder")
'set the restriction to search for message with the word "test" in the subject line

 NewSearchFolder.SearchCriteria.AsSQL = "Subject LIKE '%test%' "
'specify that the search should be performed in the Inbox and Sent Items folders
NewSearchFolder.SearchContainers.Add(DefaultStore.GetDefaultFolder(olFolderInbox))
NewSearchFolder.SearchContainers.Add(DefaultStore.GetDefaultFolder(olFolderSentMail))
'specify the search flags
NewSearchFolder.IsRecursiveSearch = false
NewSearchFolder.IsForegroundSearch = false
'we are all set: set the search parameters and let the fun begin!
NewSearchFolder.Start

 

 


Derived from: IDispatch



Properties


AsSQL

String, read/write. Get or sets the search criteria as a SQL string

The value only contains the WHERE clause (without the WHERE keyword), e.g. "(ReminderSet = 'True') OR ((IsRecurring IS NOT NULL) AND (IsRecurring = 'True'))"

 

See MAPITable.ExecSQL method help for more information.

 

'display the Reminders search folder search criteria as a SQL string

set Session = CreateObject("Redemption.RDOSession")
Session.Logon
set Store = Session.Stores.DefaultStore
set RemindersSearchFolder = Session.Stores.DefaultStore.Reminders.SearchFolder
MsgBox RemindersSearchFolder.SearchCriteria.AsSQL

 

'also see the example above

 

Restriction

Returns an Restriction object representing the search folder's criteria. For a new search folder, or if Clear method was called, this property returns NULL.

 


Methods


Clear

Clear the old restriction.

 

 

SetKind(Kind)

Sets new search criteria determined by the Kind parameter and returns a new Restriction object. The exact kind of the restriction returned is determined by Kind papameter.

Kind - one of the RestrictionKind enumeration values:

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)

see example above