RDOStore object

 

RDOStore object represents a generic message store. Depending on the actual kind of the store (see StoreKind property below), the following methods will return store objects with extra properties and methods. E.g. RDOPstStore implements all the properties and methods of the RDOStore object plus implements an extra property specific to a PST store - PstPath.

 

See RDOPstStore, RDOStore2, RDOExchangeStore, RDOExchangeMailboxStore, RDOExchangePublicFoldersStore objects below.

 

Returned by:

RDOStores: Item, AddPSTStore, AddDelegateExchangeMailBoxStore, FindExchangePublicFoldersStore, GetSharedMailbox, GetStoreFromID

RDOSession.GetStoreFromID

RDOFolder.Store

RDOMail.Store

RDOIMAPAccount.Store

RDOHTTPAccount.Store

 

 

The example below logs to the default MAPI session and prints out the file names of the PST stores and Server Distinguished Name for the Exchange stores

set Session = CreateObject("Redemption.RDOSession")
Session.Logon
for each Store in Session.Stores
  if (Store.StoreKind = skPstAnsi) or (Store.StoreKind = skPstUnicode) Then
    Debug.Print Store.Name & " - " & Store.PstPath
  ElseIf (Store.StoreKind = skPrimaryExchangeMailbox) or (Store.StoreKind = skDelegateExchangeMailbox) or (Store.StoreKind = skPublicFolders) Then
    Debug.Print Store.Name & " - " & Store.ServerDN
  End If
next

 

Properties

Methods

Events

 


Derived from: _MAPIProp -


_MAPIProp methods and properties: GetIDsFromNames, Fields(), GetPropList, GetNamesFromIDs, CopyTo, Save, MAPIOBJECT, Session


Properties


StoreKind

Returns an enumeration representing the message store kind

StoreKind - TxStoreKind:

skUnknown = 0;
skPstAnsi = 1;
skPstUnicode = 2;
skPrimaryExchangeMailbox = 3;
skDelegateExchangeMailbox = 4;
skPublicFolders = 5

set Session = CreateObject("Redemption.RDOSession")
Session.Logon

NumPstStores = 0
for each Store in Session.Stores
  if (Store.StoreKind = skPstAnsi) or (Store.StoreKind = skPstUnicode) Then
    NumPstStores = NumPstStores + 1
next

MsgBox "You have " & NumPstStores & " PST stores in the profile"

Default

boolean, read-write. Returns true if the store is default in the given profile. Set to true to make the store default

set Session = CreateObject("Redemption.RDOSession")
Session.Logon
Set Store = Session.Stores("Test PST Folders")
Store.Default = true

RootFolder

Returns RDOFolder object representing the root folder of the message store. Note that this folder is not visible to a user

 

IPMRootFolder

Returns RDOFolder object representing the top visible folder of the message store.

set Session = CreateObject("Redemption.RDOSession")
Session.Logon
Set Store = Session.Stores("Personal Folders")
set RootFolder = Store.IPMRootFolder
Debug.Print "Top Level folders in " & Store.Name & ":"
for each Folder in RootFolder.Folders
  Debug.Print Folder.Name
next

SearchRootFolder

Returns RDOFolder object representing the top search folder of the message store.

 

EntryID

string, read-only. Returns the entry id of the store

 

Name

string, read-write. Reads/sets the name of the store.

set Session = CreateObject("Redemption.RDOSession")
Session.Logon
set Store = Session.DefaultStore

MsgBox Store.Name

Reminders

Returns RDOReminders object representing the reminders collection for a given store.

'snooze all active reminders for 2 minutes
set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set Store = Session.Stores.DefaultStore
set Reminders = Store.Reminders
for each Reminder in Reminders
  if Reminder.IsVisible Then
    Reminder.Snooze(2) 'snooze for 2 minutes
  End If
next

StoreAccount

returns RDOAccount object corresponding to the Outlook account associated with the store. Read-only.

Outlook 2002 and up only.

set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
for each Store in Session.Stores
  set Account = Store.StoreAccount
  if not (Account Is Nothing) Then
    Debug.Print "Store """ & Store.Name & """ is associated to account """ & Account.Name & """. (type """ & Account.AccountTypeStr & """)"
  End If
next


Methods


GetDefaultFolder(FolderType)

FolderType - integer. The type of default folder to return. Accepts the same values as Namespace.GetDefaultFolder method in Outlook Object Model (olFolderInbox, olFolderContacts, etc).

Returns RDOFolder object.

Note that unlike RDOSession.GetDefaultStore or RDOStores.GetDefaultStore, which return default folders from the default store, this method returns the default folder from a given store, which does not have to be the default store.

E.g. if you open a delegate Exchange mailbox, this method will return the default folder of the mailbox owner. This also applies to multiple PST stores, if they have the default folder structure set up.

set Session = CreateObject("Redemption.RDOSession")
Session.Logon
set Inbox = Session.DefaultStore.GetDefaultFolder(olFolderInbox)
for each Msg in Inbox.Items
  Debug.Print(Msg.Subject)
next

AbortSubmit(MessageEntryID)

Aborts message submission for a given message.

MessageEntryID - string. The entry id of a message marked for submission.

 

CompareEntryIDs(EntryID1, EntryID2)

Checks whether the two entry ids refer to the same MAPI object. Note that entry ids cannot be directly compared and multiple entry ids can refer to the same object (e.g. in case of long term vs. short term entry id).

EntryID1 - string, entry id of the first object

EntryID2 - string, entry id of the second object

 

GetMessageFromID(EntryIDMessage, Flags)

EntryIDMessage - string representing the entry id of the message

Flags - (optional). integer flags to be used to call IMAPISession::OpenEntry. By default MAPI_BEST_ACCESS (0x10) is used. This parameter is most useful if you need to bypass the cached mode in Outlook 2003. E.g. passing MAPI_NO_CACHE (0x200) +  MAPI_BEST_ACCESS (0x10) will open the message in the best access mode bypassing the cached store.

Returns RDOMail object.

 

GetFolderFromID(EntryIDFolder, Flags)

EntryIDFolder - string representing the entry id of the folder

Flags - (optional). integer flags to be used to call IMAPISession::OpenEntry. By default MAPI_BEST_ACCESS (0x10) is used. This parameter is most useful if you need to bypass the cached mode in Outlook 2003. E.g. passing MAPI_NO_CACHE (0x200) +  MAPI_BEST_ACCESS (0x10) will open the folder in the best access mode bypassing the cached store.

Returns RDOFolder object.

 

Remove

Removes the given store from the profile.

set Session = CreateObject("Redemption.RDOSession")
Session.Logon
Set Store = Session.Stores("Test PST Folders")
Store.Remove


Events:


OnNewMail(EntryID)

Fires when a new message is delivered to the Inbox of the store.

EntryID - string, entry id (in hex) of the newly delivered message. Note that under Exchange, the entry id is a short term entry id. To retrieve the long term entry id, open the message (e.g. using RDOSession.GetMessageFromID), then read the EntryID property from the RDOMail object.

Dim WithEvents Store As Redemption.RDOStore
...

Set Session = New Redemption.RDOSession
Session.Logon

Set Store = Session.Stores.DefaultStore

...

Sub Store_OnNewMail(ByVal EntryID As String)
  Dim Msg As Redemption.RDOMail
  Set Msg = Store.GetMessageFromID(EntryID)
  MsgBox "Store_OnNewMail: " & Msg.Subject
End Sub
 

OnMessageCreated(EntryID)

Fires when a message is created in the store.

EntryID - string, entry id (in hex) of the message.

 

 

OnMessageCreatedEx(EntryID, ParentEntryID)

 

Fires when a message is created in the store.

EntryID - string, entry id (in hex) of the message.

ParentID - entry id of the parent folder

 

 

OnFolderCreated(EntryID)

Fires when a folder is created in the store.

EntryID - string, entry id (in hex) of the folder.

 

 

OnMessageCopied(EntryID)

Fires when a message is copied in the store.

EntryID - string, entry id (in hex) of the message.

 

 

OnFolderCopied(EntryID)

Fires when a folder is copied in the store.

EntryID - string, entry id (in hex) of the folder.

 

 

OnMessageDeleted(EntryID)

Fires when a message is deleted in the store.

EntryID - string, entry id (in hex) of the message.

 

 

OnMessageDeletedEx(EntryID, ParentEntryID)

 

Fires when a message is deleted in the store.

EntryID - string, entry id (in hex) of the message.

ParentID - entry id of the parent folder

 

 

OnFolderDeleted(EntryID)

Fires when a folder is deleted in the store.

EntryID - string, entry id (in hex) of the folder.

 

 

OnMessageModified(EntryID)

Fires when a message is modified in the store.

EntryID - string, entry id (in hex) of the message.

 

Dim WithEvents Store As Redemption.RDOStore
...

Set Session = New Redemption.RDOSession
Session.Logon

Set Store = Session.Stores.DefaultStore

...

Sub Store_OnMessageModified(ByVal EntryID As String)
  Dim Msg As Redemption.RDOMail
  Set Msg = Store.GetMessageFromID(EntryID)
  MsgBox "Store_OnMessageModified: " & Msg.Subject
End Sub
 

OnMessageModifiedEx(EntryID, ParentEntryID)

Fires when a message is modified in the store.

EntryID - string, entry id (in hex) of the message.

ParentID - entry id of the parent folder

 

 

OnFolderModified(EntryID)

Fires when a folder is modified in the store.

EntryID - string, entry id (in hex) of the folder.

 

 

OnMessageMoved(EntryID)

Fires when a message is moved in the store.

EntryID - string, entry id (in hex) of the message.

 

 

OnMessageMovedEx(EntryID, OldParentEntryID, NewParentEntryID)

Fires when a message is moved in the store.

EntryID - string, entry id (in hex) of the message.

OldParentEntryID - string, entry id (in hex) of the old parent folder.

NewParentEntryID - string, entry id (in hex) of the new parent folder.

 

Dim WithEvents Store As Redemption.RDOStore
...

Set Session = New Redemption.RDOSession
Session.Logon

Set Store = Session.Stores.DefaultStore

...

Sub Store_OnMessageMovedEx(ByVal EntryID As String, ByVal OldParentEntryID As String, ByVal NewParentEntryID As String)
  Dim Msg As Redemption.RDOMail
  Dim OldParent As Redemption.RDOFolder
  Dim NewParent As Redemption.RDOFolder
  Set Msg = Store.GetMessageFromID(EntryID)
  Set OldParent = Store.GetFolderFromID(OldParentEntryID)
  Set NewParent = Store.GetFolderFromID(NewParentEntryID)
  MsgBox "Store_OnMessageModifiedEx: " & Msg.Subject & _
                "; Old parent: " & OldParent.Name & _

                "; New parent: " & NewParent.Name
End Sub
 

OnMessageMoved3(EntryID, OldParentEntryID, NewParentEntryID, OldEntryID)

Fires when a message is moved in the store.

EntryID - string, entry id (in hex) of the message.

OldParentEntryID - string, entry id (in hex) of the old parent folder.

NewParentEntryID - string, entry id (in hex) of the new parent folder.

OldEntryID - string, old entry id (hex) of the message. Note that PST provider always passes an empty old entry id, but moving a folder or a message never changes its entry id, so the old entry id is the same as the new one (EntryID parameter)

 

 

OnMessageMoved3    

OnFolderMoved(EntryID)

Fires when a folder is moved in the store.

EntryID - string, entry id (in hex) of the folder.

 

 

OnFolderMovedEx(EntryID, OldParentEntryID, NewParentEntryID)

Fires when a folder is moved in the store.

EntryID - string, entry id (in hex) of the folder.

OldParentEntryID - string, entry id (in hex) of the old parent folder.

NewParentEntryID - string, entry id (in hex) of the new parent folder.

 

 

OnFolderMoved3(EntryID, OldParentEntryID, NewParentEntryID, OldEntryID)

Fires when a message is moved in the store.

EntryID - string, entry id (in hex) of the folder.

OldParentEntryID - string, entry id (in hex) of the old parent folder.

NewParentEntryID - string, entry id (in hex) of the new parent folder.

OldEntryID - string, old entry id (hex) of the folder. Note that PST provider always passes an empty old entry id, but moving a folder never changes its entry id, so the old entry id is the same as the new one (EntryID parameter)

 

 

OnSearchComplete(EntryID)

Fires when an asynchronous search in a search folder is complete

EntryID - string, entry id (in hex) of the search folder.

 

 

 

 

RDOStore2 object

This object represents an extension of the RDOStore interface and introduces one extra property: Searches (see below).

This interface can be used for any store (RDOExchangeStore, RDOExchangeMailboxStore, RDOExchangePublicFoldersStore)


Derived from: RDOStore


implements all RDOStore properties and methods


Properties


Categories

 

returns RDOCategories collection representing categories from the given store

Only Outlook 2007 (or higher) stores categories list in the default store.

 

set Session = CreateObject("Redemption.RDOSession")
Session.logon
set Store = Session.GetSharedMailbox("dmitry")
set Categories = Store.Categories
set Category = Categories.Add("Redemption Category", olCategoryColorPeach)

 

Searches

RDOSearches, read-only.

 

Returns RDOSearchescollection that provides access to the Outlook Search Folders.

 

set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set Searches = Session.Stores.DefaultStore.Searches
for each Search in Searches
    Debug.Print "-------------"
    Debug.Print Search.Name
    Debug.Print Search.SearchCriteria.AsSQL
next

 


 

 

 

 

RDOPstStore object

This object represents PST (either ANSI or Unicode) message store. Implements all RDOStore properties and methods and exposes an additional property: PstPath. This object is returned by the various RDO methods if StoreKind property is either skPstAnsi or skPstUnicode.


Derived from: RDOStore


implements all RDOStore properties and methods


Properties


PstPath

String. Returns a fully qualified path to the given PST store

 

Important note: if you set RDOSession.MAPIOBJECT property to Namespace.MAPIOBJECT property from the Outlook Object Model and your code is running outside of the outlook.exe address space (i.e. it is not a COM add-in) this property will return an error due to a MAPI bug.

set Session = CreateObject("Redemption.RDOSession")
Session.Logon
for each Store in Session.Stores
  if (Store.StoreKind = skPstAnsi) or (Store.StoreKind = skPstUnicode) Then
    Debug.Print Store.PstPath
next


Methods


 

GetNicknames

Returns RDONickNames collection representing nicknames stored in the store.

 

 

ValidateIPMTree

Validates and creates (if necessary) the following default folders in the PST store

 

Inbox

Outbox

Deleted Items

Sent Items
Calendar

Contacts

Drafts

Journal

Notes

Tasks

Junk E-mail

Folder Views

Common Views

Search Root

IPM Subtree

 

set Session = CreateObject("Redemption.RDOSession")

'open or create a new PST store
Session.LogonPstStore("c:\temp\test_default_folders.pst", 1, "Test Default Folders Store")
set Store = Session.Stores.DefaultStore
Store.ValidateIPMTree

'now create a new contact in the default Contacts folder of the newly created PST store

set Contact = Store.GetDefaultFolder(olFolderContacts).Items.Add
Contact.Email1Address = "test_address@dimastr.com"
Contact.FirstName = "Dmitry"
Contact.LastName = "Streblechenko"
Contact.Save


 

 

RDOExchangeStore object

This object represents an Exchange message store. RDOExchangeMailboxStore and RDOExchangePublicFoldersStore are derived from this interface. Implements all RDOStore properties and methods and exposes an additional property: ServerDN.


Derived from: RDOStore


implements all RDOStore properties and methods


Properties


ServerDN

String. Returns an Exchange Server distinguished name

set Session = CreateObject("Redemption.RDOSession")
Session.Logon
for each Store in Session.Stores
  if (skPrimaryExchangeMailbox) or (Store.StoreKind = skDelegateExchangeMailbox) or (Store.StoreKind = skPublicFolders) Then
    Debug.Print Store.ServerDN
next


 

 

RDOExchangeMailboxStore object

This object represents an Exchange Server mailbox message store. Implements all RDOExchangeStore properties and methods and exposes an additional property: Owner. This object is returned by the various RDO methods if StoreKind property is either skPrimaryExchangeMailbox or skDelegateExchangeMailbox.


Derived from: RDOExchangeStore


implements all RDOExchangeStore properties and methods


Properties


CalendarOptions

Returns RDOCalendarOptions object that represents the calendaring options (auto-accept, free/busy data, etc).

Read-only.

 

set Session = CreateObject("Redemption.RDOSession")
Session.Logon
set CalendarOptions = Session.Stores.DefaultStore.CalendarOptions
CalendarOptions.AutoAccept = true

 

IsCached

Boolean. read/write. Outlook 2003 and up only.

Returns true if the Exchange mailbox is cached. Note that delegate mailboxes are never cached.

Setting this property won't take effect until the next time MAPI logs to the profile.

Corresponds to the "Use Cached Exchange Mode" checkbox in the Exchange provider properties dialog.

 

JunkEmailOptions

Returns RDOJunkEmailOptions object representing mailbox Junk E-mail options.

Note that mailbox Junk E-mail options can be different from the profile-wide options: mailbox Junk E-mail options can be retrieved or set for a mailbox other than the primary mailbox in the profile (see the example)

 

'make sure messages from a client are never marked as spam

set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set Store = Session.Stores.GetSharedMailbox("OtherUser")
set JunkOptions = Store.JunkEmailOptions
JunkOptions.TrustedSenders.Add "@ReallyBigClient.com"
JunkOptions.Save

 

OstPath

String, read only.

Returns full path to the local OST file used to cache the mailbox.

 

Owner

AddressEntry. Returns an Address Book object that represents the owner of the mailbox

set Session = CreateObject("Redemption.RDOSession")
Session.Logon
for each Store in Session.Stores
  if (Store.StoreKind = skPrimaryExchangeMailbox) or (Store.StoreKind = skDelegateExchangeMailbox) Then
    Debug.Print Store.Owner.Name
next

OutOfOfficeAssistant

Returns an RDOOutOfOfficeAssistant object that allows to set the Out-Of-Office state and reply text.

skPrimaryExchangeMailbox = 3
skDelegateExchangeMailbox = 4
set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set Store = Session.Stores.DefaultStore
if (Store.StoreKind = skPrimaryExchangeMailbox) or (Store.StoreKind = skDelegateExchangeMailbox) Then
  set OOFAsistant = Store.OutOfOfficeAssistant
  OOFAsistant.OutOfOffice = true
  OOFAsistant.OutOfOfficeText = "Sorry, I am out of office at the moment!"
Else
  MsgBox "Out Of Office Assistant is only available for the Exchange mailboxes"
End If

Rules

RDORules, read-only. Returns a collection representing rules defined for the given mailbox.

set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
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


Methods


GetFolderFromSourceKey(SourceKey)

Returns a folder (RDOFolder) object corresponding to the given source key (PR_SOURCE_KEY).

SourceKey - the value of the PR_SOURCE_KEY. Either a variant array of bytes as returned by RDOFolder.Fields() or a string with a hex representation of  PR_SOURCE_KEY.

 

Normally folders can be reopened using RDOSession.GetFolderFromID or RDOStore.GetFolderFromID, but under Exchange the values of entry ids can differ depending on how the object is opened (e.g. whether it comes from the primary Exchange mailbox or a delegate mailbox, etc).

The value of  PR_SOURCE_KEY for a given folder or message is always the same. GetFolderFromSourceKey and GetMessageFromSourceKey allow to retrieve folders and messages when, for example, the folder or a message is retrieved by one user, stored in an external DB and then ubsequently retrieved in another user's context.

 

This method only works in the online mode: the profile used in RDOSession.Logon must either be configured to be in the online mode or RDOSession.LogonExchangeMailbox must be used.

 

PR_SOURCE_KEY = &H65E00102
skPrimaryExchangeMailbox = 3
skDelegateExchangeMailbox = 4

skPublicFolders = 5
'retrieve the values of source keys for a message and its parent folder
set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set Msg = Session.GetMessageFromID(Application.ActiveExplorer.Selection.Item(1).EntryID)
MessageSourceKey = Msg.Fields(PR_SOURCE_KEY)
FolderSourceKey = Msg.Parent.Fields(PR_SOURCE_KEY)

'convert the source keys to hex strings suitable for storage
'in a database.
'GetMessageFromSourceKey and GetFolderFromSourceKey can take either a variant
'array of bytes as returned by Fields() for the PT_BINARY properties or a hex string, so it works either way
set Utils = CreateObject("Redemption.MAPIUtils")
strMessageSourceKey = Utils.HrArrayToString(MessageSourceKey)
strFolderSourceKey = Utils.HrArrayToString(FolderSourceKey)

'we can (now or later) use the values of the source keys to reopen a messsage or a folder
set Store = Session.Stores.DefaultStore
if (Store.StoreKind = skPrimaryExchangeMailbox) or (Store.StoreKind = skDelegateExchangeMailbox) or (Store.StoreKind = skPublicFolders) Then
  set NewMsg = Store.GetMessageFromSourceKey(strFolderSourceKey, strMessageSourceKey)
  MsgBox "Message subject: " & NewMsg.Subject
  set NewFolder = Store.GetFolderFromSourceKey(strFolderSourceKey)
  MsgBox "Folder name: " & NewFolder.Name
End If
 

 

GetMessageFromSourceKey(FolderSourceKey, MessageSourceKey)

Returns a message (RDOMail, RDOContactItem, etc depending on the message class) object corresponding to the given source key (PR_SOURCE_KEY).

FolderSourceKey - the value of the parent folder's PR_SOURCE_KEY property. Either a variant array of bytes as returned by RDOFolder.Fields() or a string with a hex representation of  PR_SOURCE_KEY.

 

MessageSourceKey - the value of the message PR_SOURCE_KEY property. Either a variant array of bytes as returned by RDOFolder.Fields() or a string with a hex representation of  PR_SOURCE_KEY.

 

See GetFolderFromSourceKey above.

 

GetNicknames Returns RDONickNames collection representing nicknames stored in the store.

 


 

 

 

 

RDOExchangePublicFoldersStore object

This object represents an Exchange Server mailbox message store. Implements all RDOExchangeStore properties and methods. There are no additional properties at this time. This object is returned by the various RDO methods if StoreKind property is skPublicFolders.


Derived from: RDOExchangeStore


implements all RDOExchangeStore properties and methods


Properties


IsCached

Boolean. read/write. Outlook 2003 and up only.

Returns true if the Exchange mailbox is cached. Note that delegate mailboxes are never cached.

Setting this property won't take effect until the next time MAPI logs to the profile.

Corresponds to the "Download Public Folder Favorites" checkbox in the Exchange provider properties dialog.

 

     

Methods


GetFolderFromSourceKey(SourceKey)

 

See RDOExchangeMailboxStore.GetFolderFromSourceKey above

 

 

GetMessageFromSourceKey(FolderSourceKey, MessageSourceKey)

 

See RDOExchangeMailboxStore.GetMessageFromSourceKey above