|
RDOFolders object collection |
RDOFolders collection represents the
subfolders of a given RDOFolder object.
Returned by:
RDOFolder.Folders
The example below logs to the default
MAPI session and prints out the names of all the subfolders of the root IPM
folder of the default store:
set Session =
CreateObject("Redemption.RDOSession")
Session.Logon
set IPMRoot = Session.Stores.DefaultStore.IPMRootFolder
for each Folder in IPMRoot.Folders
Debug.Print(Folder.Name)
next |
Properties
Methods
Events
|
Derived from:
IDispatch
|
|
Properties |
|
Count |
integer. Returns the number
of folders in the collection |
set Session =
CreateObject("Redemption.RDOSession")
Session.Logon
set Folder = Session.Stores.DefaultStore.IPMRootFolder.Folders("Test
folder")
MsgBox "Number of subfolders: " & Folder.Folders.Count |
_Item(Index) |
Index - variant:
integer or a string. A default object property.
Retrieves a subfolder with a
given index (1 to Count) or a given name
Returns
RDOFolder object |
|
RawTable |
IUnknown, read-only. Returns the IMAPITable Extended MAPI interface used
internally by the RDOItems collection |
|
Session |
RDOSession, read-only. Returns the parent
MAPI session represented by the RDOSession object |
|
MAPITable |
MAPITable, read-only. Returns the
MAPITable Redemption object which can be used to manipulate the
collection (restrict, find, etc). |
|
|
Methods |
|
Item(Index) |
Index - variant:
integer or a string.
Retrieves a subfolder with a
given index (1 to Count) or a given name
Returns
RDOFolder object
|
|
Add(Name, Type) |
Adds new subfolder to the
specified folder. Returns an RDOFolder
object.
Name - string. The
name of the folder to add
Type - variant,
optional. If specified, can be either one of the
rdoDefaultFolders enums
(olFolderCalendar, olFolderContacts, etc) or a string representing the
container class (PR_CONTAINER_CLASS in Extended MAPI), e.g. "IPF.Contact"
|
set Session =
CreateObject("Redemption.RDOSession")
Session.Logon
set IPMRoot = Session.Stores.DefaultStore.IPMRootFolder
set NewFld = IPMRoot.Folders.Add("Test Folder") |
AddSearchFolder(Name, Type) |
Adds new search folder to the
specified folder. Returns an
RDOSearchFolder object.
Name - string. The
name of the search folder to add
Type - variant,
optional. If specified, can be either one of the OlDefaultFolders enums
(olFolderCalendar, olFolderContacts, etc) or a string representing the
container class (PR_CONTAINER_CLASS in Extended MAPI), e.g. "IPF.Contact"
|
|
Find(Filter)
|
Locates and returns the first
folder (RDOFolder) matching the specified
SQL style query (see example).
If no folders matches the query,
null is returned.
To locate subsequent matching
items, call FindNext repeatedly until null is returned.
See also Restrict
method.
Filter - string. SQL
style query specifying the condition. Can either be a WHERE part only
(e.g. "Name LIKE 'C%' ") or a complete SQL expression with
the SELECT, WHERE and ORDER BY clauses (see example).
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
IMAPIFolder button on the
OutlookSpy
toolbar, select the property, see the "DASL" edit box on he right hand
side of the window.
Including the SELECT clause
allows Redemption to pre-fetch the properties from the folder hierarchy
table without opening the item resulting in a significant performance
gain (see example). If you later access a property not specified in the
SELECT clause, Redemption will open the item.
Including the ORDER BY clause
sorts the collection in the specified order.
|
|
FindNext
|
Returns the next folder
matching the restriction specified in a previous call to Find. It
returns null if no next object exists, for example, if already
positioned at the end of the collection.
An error will be raised if
the Find method was not previously called.
|
|
GetFirst |
Returns the first folder in
the specified RDOFolders collection. Returns Nothing if no first folder
exists, for example, if there are no subfolders.
|
|
GetLast |
Returns the last folder in
the specified RDOFolders collection. Returns Nothing if no last folder
exists, for example, if there are no subfolders.
|
|
GetNext |
Returns the next folder in
the specified RDOFolders collection. It returns Nothing if no next
folder exists, for example, if already positioned at the end of the
collection. |
|
GetPrevious |
Returns the previous folder
in the specified RDOFolders collection. It returns Nothing if no
previous folder exists, for example, if already positioned at the
beginning of the collection. |
|
OpenOrAdd(Name, Type)
|
Opens the existing folder or
adds new subfolder to the
specified folder. Returns an RDOFolder
object.
This method is more efficient
(it is implemented on the store provider level) than the usual practice
of first attempting to call RDOFolders.Add, catch the
exception, and then retrieve the existing folder by name using
RDOFolders.Item (or
RDOFolders[]).
Name - string. The
name of the folder to add
Type - variant,
optional. If specified, can be either one of the
rdoDefaultFolders enums
(olFolderCalendar, olFolderContacts, etc) or a string representing the
container class (PR_CONTAINER_CLASS in Extended MAPI), e.g. "IPF.Contact"
|
|
OpenOrAddSearchFolder(Name, Type)
|
Opens the existing folder or
adds new search folder to the
specified folder. Returns an
RDOSearchFolder object.
Name - string. The
name of the search folder to add
Type - variant,
optional. If specified, can be either one of the OlDefaultFolders enums
(olFolderCalendar, olFolderContacts, etc) or a string representing the
container class (PR_CONTAINER_CLASS in Extended MAPI), e.g. "IPF.Contact"
|
|
Remove(Index) |
Deletes a subfolder with the
specified index (1 to Count)
Index - integer, 1
through Count |
|
Restrict(Filter)
|
Applies a filter to the
RDOFolders collection, returning a new
RDOFolders collection
containing all of the items from the original that match the filter. The
original RDOFolders collection is not affected.
This method is an alternative
to using the Find method or FindNext method to iterate
over specific subfolders within a collection. The Find or FindNext
methods are faster than filtering if there are a small number of items.
The Restrict method is significantly faster if there is a large
number of items in the collection, especially if only a few items in a
large collection are expected to be found.
Filter - string. SQL
style query. See Find method help for more information
|
|
Sort(Columns, Descending)
|
Sorts the collection of
folders
by the specified property or properties.
Columns - can either
be an integer property tag or a variant array of integer property tags
or a comma separated string of the OOM or DASL property names (see
example)
Descending - optional.
Either a boolean or
a variant array of boolean values corresponding to the Columns parameter.
|
'Sort subfolders in the order displayed by Outlook
set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set folder = Session.Stores.DefaultStore.IPMRootFolder
'sort on two properties PR_SORT_POSITION and
PR_DISPLAY_NAME_W
Dim sortProps()
Redim sortProps(1)
'PR_SORT_POSITION
sortProps(0) = "http://schemas.microsoft.com/mapi/proptag/0x30200102"
'PR_DISPLAY_NAME_W
sortProps(1) = "http://schemas.microsoft.com/mapi/proptag/0x3001001F"
dim sorts()
Redim sorts(1)
sorts(0) = false
sorts(1) = false
set subFolders = folder.Folders
subFolders.Sort sortProps, sorts
for each f in subFolders
isHidden = f.Fields(&H10F4000B) 'PR_ATTR_HIDDEN
if not (isHidden) Then
Debug.Print f.Name
End If
next
|
|
Events: |
|
FolderChange(Folder) |
Fires when a subfolder in the
hierarchy table is modified.
Folder -
RDOFolder object
|
|
FolderAdd(Folder) |
Fires when a new subfolder is
added to the hierarchy table.
Folder -
RDOFolder object
|
Dim WithEvents InboxFolders
As Redemption.RDOFolders
...
Set Session = New
Redemption.RDOSession
Session.Logon
Set Store = Session.Stores.DefaultStore
Set Inbox = Store.GetDefaultFolder(olFolderInbox)
Set InboxFolders = Inbox.Folders
...
Sub
InboxFolders_FolderAdd(ByVal Folder As RDOFolder)
MsgBox "New subfolder added to the Inbox: " & Folder.Name
End Sub |
FolderRemove(InstanceKey) |
Fires when a folder is
removed from the hierarchy table.
By the time this asynchronous even is fired, the folder is already
deleted, hence no entry id is available.
InstanceKey - a hex
value of the PR_INSTANCE_KEY property of the deleted table row. Note
that PR_INSTANCE_KEY is not available from the folder itself, only from
the MAPI table (see MAPITable property). InstanceKey is only guaranteed
to be the same for the same instance of the table, hence this event is
useful only if the value of PR_INSTANCE_KEY was previously cached.
|
|
CollectionModified |
Fires when the hierarchy table is modified and the underlying MAPI
implementation cannot provide more detailed information about the
change, e.g. when too many folders were modified at the same time.
When the event fires, it must
be assumed that the entire contents of the collection are no longer
valid. |
|
|
|