RDOSession object is the top level object in the RDO
object hierarchy from which all
other objects are retrieved. To be able to use RDOSession object properties and
methods, log on to a MAPI session first by either setting the MAPIOBJECT
property or calling Logon, LogonExchangeMailbox or LogonPstStore methods.
The example below logs to the default MAPI session and prints out the subjects
of all messages in the Inbox folder:
The example below connects to the
MAPI session used by Outlook (Application object below refers to an instance of
the Outlook.Application object) and prints out the subjects
of all messages in the Inbox folder:
|
Derived from:
IDispatch
|
|
Properties: |
|
Accounts |
RDOAccounts, read-only. Returns the collection representing mail,
store and address book accounts in the current profile.
Outlook 2002 and up only. |
set Session =
CreateObject("Redemption.RDOSession")
Session.Logon
set Accounts = Session.Accounts
for each Account in Accounts
Debug.Print Account.Name
next |
AddressBook |
RDOAddressBook, read-only.
Returns the object exposing the Address Book related functionality |
set AB = Session.AddressBook
set Recips = AB.ShowAddressBook
MsgBox "You have selected " &
Recips.Count & " recipients" |
AuthKey |
string, write-only. Sets the
authentication key - see Security. |
|
Categories |
returns
RDOCategories collection representing categories from the local machine
RDOCategories collection first attempts to read the category list
from the default store in the profiles (where Outlook 2007 stores it).
If no categories are present in the default store, Redemption tries to
read the categories list from the registry if Outlook 2003 or older is
installed.
|
set Session =
CreateObject("Redemption.RDOSession")
Session.Logon
set Categories = Session.Categories
for each Category in Categories
Debug.Print Category.Name
next
|
ConnectEncryptData |
Boolean, read/write.
Setting this property to true forces LogonExchangeMailbox
method to set the PR_PROFILE_UI_STATE property to 0x4100 to force MAPI to
encrypt the data.
|
Set oRDOSession = CreateObject("Redemption.RDOSession")
oRDOSession.ParentWindow = Application.ActiveExplorer
oRDOSession.ConnectEncryptData = true
oRDOSession.LogonExchangeMailbox "dmitry streblechenko",
"myserver.com" |
ConnectIgnoreNoPF |
Boolean, read/write.
Setting this property to true forces LogonExchangeMailbox
method to set the CONNECT_IGNORE_NO_PF bit in the PR_PROFILE_CONNECT_FLAGS
property to tell MAPI that it is Ok to connect even if the PF store is not
available.
Note that only Outlook 2010 and the standalone version of MAPI understand this
property.
|
|
CurrentUser |
RDOAddressEntry, read-only.
Returns the address entry representing the default user identity in the
current MAPI session.
Note that if the RDOSession object was initialized by setting its
MAPIOBJECT property to Namespace.MAPIOBJECT
from OOM, the current user returned by this property can vary depending
on the store currently selected in Outlook.
If the goal is to retrieve the default mail account, using the first
RDOAccount object from the
RDOSession.Accounts.GetOrders(acMail) collection might be a
better alternative.
|
set Session =
CreateObject("Redemption.RDOSession")
Session.Logon MsgBox "Current user's name:
" & Session.CurrentUser.Name
|
CurrentWindowsUser |
RDOAddressEntry, read-only. Returns
the address entry representing the identity of the current Windows user.
Accessing this property does
not require an active MAPI session, i.e. it can be accessed even if
Logon method had not been called.
Note that the properties of
the current Windows user are retrieved directly from the Active
Directory, which means the parent process must be running under an
identity of a domain user and the AD server must be accessible.
Note: the following
RDOAddressEntry properties will return
null in the current version: Delegates, IsDelegateFor,
IsMemberOfDL, Reports
|
set Session =
CreateObject("Redemption.RDOSession")
MsgBox "Your SMTP address is " & Session.CurrentWindowsUser.SmtpAddress |
ExchangeConnectionMode |
Returns or sets on of
rdoExchangeConnectionMode enum values that indicate the current
connection mode used in the profile.
When setting the property,
only olCachedDisconnected (the same as setting the
Offline property to true), olCachedConnectedHeaders
, olCachedConnectedDrizzle, olCachedConnectedFull
can be used.
rdoExchangeConnectionMode can be one of the following constants:
olCachedConnectedDrizzle |
600 |
The account is using
cached Exchange mode such that headers are downloaded first,
followed by the bodies and attachments of full items. |
olCachedConnectedFull |
700 |
The account is using
cached Exchange mode on a Local Area Network or a fast
connection with the Exchange server. The user can also select
this state manually, disabling auto-detect logic and always
downloading full items regardless of connection speed. |
olCachedConnectedHeaders |
500 |
The account is using
cached Exchange mode on a dial-up or slow connection with the
Exchange server, such that only headers are downloaded. Full
item bodies and attachments remain on the server. The user can
also select this state manually regardless of connection speed. |
olCachedDisconnected |
400 |
The account is using
cached Exchange mode with a disconnected connection to the
Exchange server. |
olCachedOffline |
200 |
The account is using
cached Exchange mode and the user has selected
Work Offline from the File menu. |
olDisconnected |
300 |
The account has a
disconnected connection to the Exchange server. |
olNoExchange |
0 |
The account does not
use an Exchange server. |
olOffline |
100 |
The account is not
connected to an Exchange server and is in the classic offline
mode. This also occurs when the user selects Work
Offline from the File menu. |
olOnline |
800 |
The account is
connected to an Exchange server and is in the classic online
mode. |
|
|
ExchangeMailboxServerName
|
Returns a String value that
represents the name of the Exchange server on which the active mailbox
is hosted. Read-only.
|
|
ExchangeMailboxServerVersion |
Returns a String value that
represents the full version of the Exchange server on which the active
mailbox is hosted.
If Exchange is not used by
the current profile, an empty string is returned.
Read-only.
|
|
FastShutdownSupported |
Boolean, read-only. Returns
true if the current version of Outlook and all providers in the profile
support fast shutdown.
Only Outlook 2007 SP2 or
higher supports fast shutdown.
See the following for more
information:
http://blogs.msdn.com/stephen_griffin/archive/2009/03/03/fastest-shutdown-in-the-west.aspx
|
set Session =
CreateObject("Redemption.RDOSession")
Session.Logon
Debug.Print "Stores in the profile: " & Session.Stores.Count
if Session.FastShutdownSupported Then
Session.DoFastShutdown
Else
Session.Logoff
End If
|
Favorites
|
RDOFavorites, read-only.
Returns the list of folders marked as favorites in the default store in
the current profile.
|
Set
MySession =
CreateObject("Redemption.RDOSession")
MySession.MAPIOBJECT = Application.Session.MAPIOBJECT
Set Inbox =
MySession.GetDefaultFolder(olFolderInbox)
'open or add a folder
set
NewFolder =
Inbox.Folders.OpenOrAdd("The
Favorite Folder")
set Favorites =
MySession.Favorites
'try to retrieve an existing favorite object by the
folder
'can also be retrieved by name or index
set Favorite =
Favorites.Item(NewFolder)
if Favorite
Is
Nothing
Then
set Favorite = Favorites.Add(NewFolder)
End
If
|
HeadersOnlyOnSlowConnection
|
boolean, read/write. Corresponds to "Send
/ Receive | Download | On Slow Connectiosn Download Only Headers" in the
Outlook UI.
|
|
JunkEmailOptions |
Returns
RDOJunkEmailOptions object
representing profile-wide Junk E-mail options, which are saved in the
profile data (registry) as well as the primary message store in case of
an Exchange mailbox.
Profile and mailbox options
are reconciled based on the last modification time. |
set Session =
CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set JunkOptions = Session.JunkEmailOptions
for each address in JunkOptions.BlockedSenders
Debug.Print address
next
|
LoggedOn |
boolean, read-only. Returns
true if logged on, false otherwise. |
if not Session.LoggedOn Then
Session.Logon
End If
|
MAPIDllFileName
|
Returns full path to the MAPI dll (olmapi32.dll, msmapi32.dll or
exmapi32.dll).
|
|
MAPIFormMgr
|
Returns RDOMAPIFormMgr
that exposes MAPI forms in the current MAPI session; it corresponds to the
IMAPIFormMgr Extended MAPI interface.
|
set
Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set
PersonaFormContainer = Session.MAPIFormMgr.OpenLocalFormContainer
for
each
FormInfo
in
PersonaFormContainer
Debug.Print
FormInfo.DisplayName
next
|
MAPIOBJECT |
IMAPISession Extended MAPI
object, read-write.
Allows to set the MAPI session to be used without explicitly logging to
a MAPI profile. Useful if RDO is used in an environment where a MAPI
session is already available (e.g. a COM add-in).
If you set the MAPIOBJECT property, do not call RDOSession.Logoff as
that will render the original session invalid as well.
Important note: if you set this property to Namespace.MAPIOBJECT property from the Outlook Object Model and your
code is running outside the outlook.exe address space (i.e. it is not
a COM add-in) some RDO features (RDOFolder.ACL,
GetSharedDefaultFolder, GetSharedMailbox, etc) will not function properly
due to bugs in the MAPI COM marshaling support.
|
'use the same MAPI object
as Outlook
'Namespace is returned
from Application.GetNamespace("MAPI") in OOM
set Session =
CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT =
Namespace.MAPIOBJECT |
MAPITimeoutShort
|
Boolean, read/write.
By default this property is true, which causes Redemption to use the
MAPI_TIMEOUT_SHORT flag when logging to a MAPI profile (Logon,
LogonExchangeMailbox, LogonPstStore). If one of the MAPI providers does
not finish initialization within 5 seconds or so, the call will return
MAPI_E_TIME_OUT error.
Reset this property to false if you are accessing Exchange over a slow
or high latency network.
|
|
MAPIVersion
|
Returns a string representing the version of the MAPI system
(olmapi32.dll, msmapi32.dll or exmapi32.dll).
|
|
Offline |
Boolean. read/write. Sets the "Work Offline" option in the current
session.
Note that to affect the Offline state in Outlook, you must use the MAPI
session returned from Namespace.MAPIOBJECT property in OOM and run in
the outlook.exe address space (which means your code must be in an
Outlook COM add-in or a VBA script).
Note: this property is only supported in
Outlook 2007 or newer.
|
set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
Session.Offline = true
|
OutlookVersion |
Returns a String value that
represents the full version of Outlook. If Outlook is not installed, an
empty string is returned.
Read-only.
|
|
ParentWindow
|
Object, read/write.
This can be set either to a
window handle (HWND) or to an object that supports the
IOleWindow interface (such as Explorer or Inspector
objects in the Outlook Object Model).
Setting this property to 1
forces Redemption to use the value returned by the GetForegroundWindow
Windows API function, setting it to 2 uses the value from
GetDesktopWindow.
Setting that property allows
MAPI to display dialog boxes when needed, for example when logging to a
profile (Logon, LogonExchangeMailbox), opening a message store (LogonPstStore,
AddPstStoreWithPassword, GetStoreFromID, GetSharedMailbox) or when
resoling names (ResolveName, Resolve, etc).
This property has no effect
when running in a service.
|
set Session =
CreateObject("Redemption.RDOSession")
Session.ParentWindow = Application.ActiveExplorer
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set AdrrEntry = Session.AddressBook.ResolveName("d")
|
ProfileName |
string, read-only. Returns
the name of the currently used MAPI profile. |
MsgBox Session.ProfileName |
Profiles |
RDOProfiles, read-only. Returns a collection representing the list
of profiles for the current Windows user.
|
set Session =
CreateObject("Redemption.RDOSession")
Debug.Print("Default profile: " & Session.Profiles.DefaultProfileName)
Debug.Print("Profiles: ")
Debug.Print("------")
for each Name in Session.Profiles
Debug.Print(Name)
next
|
SkipAutodiscoverLookupInAD |
Boolean, read/write.
Normally, Redemption methods that require autodiscover XML (such as LogonHostedExchangeMailbox,
GetSharedMailbox, free/busy methods, etc.) look (each in a separate thread) for
the autodiscover XML in a few predetermined HTTP locations with a timeout of 5
seconds. A lookup in the Active Directory however, especially if the remote
server cannot be contacted through LDAP, can take a long time to time out. Set
SkipAutodiscoverLookupInAD property to true if you are connecting to a hosted Exchange
server. Leave it as false if you are connecting to an on-premises Exchange serer
that does not publish autodiscover through HTTP.
|
|
Signatures
|
Returns RDOSignatures collection
representing Outlook signatures in the current profile.
|
'enumerate all signatures
set
Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
for
each
Signature
in
Session.Signatures
Debug.Print Signature.Name
next
|
SocialConnectors
|
Returns RDOSocialConnectors
collection representing Social connectors (such as Facebook or LinkedIn)
configured in the current profile. |
userToFind = "user@domain.demo"
set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set SocialConnector = Session.SocialConnectors.Item("Linkedin")
set persons = SocialConnector.FindPerson(userToFind)
for each person in persons
MsgBox person.FullName
next
|
Templates
|
Returns
RDOTemplates collection representing templates in
the default Exchange mailbox in the profile.
|
RDOTemplates templates = session.Templates;
RDOTemplate template1 = templates.Add(
"See report",
"Please see the attached
last quarter report.");
RDOTemplate template2 = templates.Add(
"Submit
support ticket",
@"Please
submit support ticket at<br>"+
"<a href=""https://www.mycompany.demo/support"">"
+
"https://www.mycompany.demo/support</a>.");
templates.Save();
//can also call
RDOTemplate.Save
|
Stores |
RDOStores, read-only. Returns
the collection of stores in the current profile. |
set Session =
CreateObject("Redemption.RDOSession")
Session.Logon
MsgBox Session.Stores.DefaultStore.Name
|
TimeZones |
RDOTimezones, read-only. Returns collection representing time zones
available in Windows. |
set Session =
CreateObject("Redemption.RDOSession")
set Timezones = Session.Timezones
for each TZ in Timezones
Debug.Print TZ.Name
next
|
Version |
String, read-only. returns
the Redemption file version, e.g. "5.10.0.9602"
|
|
UseEWSImpersonation |
If set to true, forces Redemption to add the ExchangeImpersonation
header to the EWS calls
|
|
|
Methods |
|
CacheAutodiscoverXml(SMTPAddress, AutodiscoverXml)
|
SMTPAddress - string. The SMTP address of an Exchange
mailbox for which autodiscover XML is to be cached.
AutodiscoverXml- string, Autodiscover XML to be cached.
A valid url (http or https) can also be passed - the specified url will later
be used to retrieve the Autodiscover XML for the specified SMTP address whenever
Redemption will need it (GetSharedDefaultMailbox,
LogonHostedExchangeMailbox, etc.) thus avoiding the need to probe
multiple Autodiscover urls (some of which can take a considerable amount of time
to return or timeout).
RDOSession.CacheAutodiscoverXml and
RDOSession.GetAutodiscoverXml
methods allow to cache autodiscover XML instead of retrieving it each
time it is needed. This allows to speed up Redemption methods that require
autodiscover, such as RDOSession.LogonHostedExchangeMailbox,
RDOSession.GetArchiveMailbox, ,
RDOSession.GetSharedMailbox,
RDOOutOfOfficeAssistant,
|
|
CreateOneOffEntryID(Name,
AddressType, Address, SendRichInfo, UseUnicode)
|
Create a one-off entry id
corresponding to the specified name, address type and address. Useful if
you need to set the flag (MAPI_ONE_OFF_NO_RICH_INFO) governing whether a
message will be sent in the RTF format or not.
This method does not require
an active MAPI session.
Name - string, name of
the recipient
AddressType - string,
address type
Address -
string, e-mail address
SendRichInfo -
optional, boolean.
If true, e-mails will be sent in the RTF format
UseUnicode - optional, boolean.
Determines whether the name and address are embedded in the Unicode
format. Note that Outlook 2000 cannot handle one-off entry ids in the
Unicode format. |
|
IsAttachmentBlocked(FileName)
|
Returns True if the given file name is blocked by Outlook and False
otherwise.
The method is a wrapper for the
IAttachmentSecurity MAPI interface
FileName - the file name to be checked. The file does
need to physically exist. Passing the path information is not required.
|
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
MsgBox Session.IsAttachmentBlocked( "MyHarmlessFile.txt")
|
Logoff
|
Logs off from the current
MAPI session.
Note:
If you are setting the RDOSession.MAPIOBJECT property to
Namespace.MAPIOBJECT from the Outlook Object Model or another RDOSession,
do not call Logoff as it will render the original session invalid.
|
set Session =
CreateObject("Redemption.RDOSession")
Session.Logon
MsgBox "There are " &
Session.Stores.Count & " stores in the default profile"
|
Logon(ProfileName,
Password, ShowDialog, NewSession, ParentWindowHandle, NoMail) |
Logs to the specified
profile.
ProfileName - string,
optional. If ProfileName is not specified or is an empty string, the
default profile is used.
Password - string,
optional.Presently this parameter is only used by the PST provider if
the PST store is protected with a password. This is *not* a Windows
account password.
ShowDialog - boolean,
optional. If true, the dialog selection dialog is used.
NewSession - boolean,
optional. If true, a new MAPI session is created; if false, RDO will try
to connect to the existing MAPI session
ParentWindowHandle -
integer, optional. Window handle of the window to be used as the parent
of the dialogs shown by Logon()
NoMail - boolean,
optional. If true, MAPI session is initialized without starting the MAPI
spooler.
|
set Session =
CreateObject("Redemption.RDOSession")
Session.Logon("Outlook")
set Session =
CreateObject("Redemption.RDOSession")
|
LogonExchangeMailbox(User,
ServerName) |
Log to a temporary profile
that points to the specified Exchange mailbox.
Exchange only.
User - string. Name, address
or distinguished name identifying the mailbox, e.g. "UserName", "user@mydomain.com",
"/o=MyCompany/.../cn=UserName"
ServerName - name or address of the Exchange server., e.g.
"mail", "mail.mydomain.com".
|
set Session =
CreateObject("Redemption.RDOSession")
Session.LogonExchangeMailbox("dmitry@", "mail")
MsgBox Session.Stores.Count |
LogonHostedExchangeMailbox(SMTPAddress, UserName,
Password)
|
Similar to LogonExchangeMailbox, logs to a temporary profile that
points to an Exchange mailbox owned by the specified SMTP address.
The connection settings are retrieved using
Exchange Autodiscover Service and a temporary profile is created
that uses RPC-over-HTTP (ROH) to connect to the mailbox under Outlook
2013.
When Outlook 2016 is used, the profile is automatically configured by
the MSEMS provider to use either MAPI-over-HTTP or RPC-over-HTTP
depending on the Exchange Server version and its settings.
No credentials prompt will be show under Outlook 2010 or newer. Under
Outlook 2007, the prompt is still shown. The dialog will use the window
specified by the RDOSession.ParentWindow
property as the parent window.
SMTPAddress - string. The SMTP address of the user who
owns the mailbox. This parameter is used to retrieve the autodiscover
XML that contains the connection settings.
UserName - string. The user name to be used to log to
the specified mailbox. In most cases, the user name is the same as the
SMTPAddress parameter, but can also be in the Domain\Name form
when NTLM authentication is used.
Password - string. the mailbox password.
|
set Session = CreateObject("Redemption.RDOSession")
Session.ParentWindow = SomeHWND
Session.LogonHostedExchangeMailbox _
"user@mydomain.onmicrosoft.com", _
"user@mydomain.onmicrosoft.com", _
"<thePassword>"
Set oRDOFolder = Session.GetDefaultFolder(olFolderInbox)
for each item in oRDOFolder.Items
debug.print item.subject
next
|
LogonPstStore(Path,
Format, DisplayName, Password, Encryption) |
LogonPstStore method,
in addition to the Logon and LogonExchangeMailbox methods
and setting the MAPIOBJECT property, allows to log to MAPI.
LogonPstStore, similar
to the LogonExchangeMailbox method, creates a temporary profile,
adds the specified PST store (new or existing) to that temporary
profile, and log to the profile. The temporary profile is immediately
deleted, so it will never be visible to an end user. LogonPstStore
is useful if you need to process a PST file without explicitly creating
a new profile using ProfMan and/or without
adding the temporary PST store to an existing profile using
RDOSession.Stores.AddPstStore:
Path - string,
required, path to
the PST file. If the file does not exist, a new PST store will be
created.
Format - integer,
optional. The format of the PST file if a new store is to be created.
Can be one of the rdoStoreType enums: olStoreDefault (1), olStoreUnicode (2), olStoreANSI (3).
DisplayName - string,
optional. The display name of the store if one is to be created.
Password - string, optional. The PST file pssword.
Encryption - one of
the rdoPstEncryption enums, optional. Specifies the encryption level to
be used when creating a new PST file.
psteCompressableEncryption
(1)
psteBestEncryption (2)
psteNoEncryption (0)
Returns
RDOPstStore object. The same
store can be retrieved after calling LogonPstStore from the
RDOSession.Stores.DefaultStore.
|
'create initialize first RDOSession object that shared the MAPI session with Outlook
set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
'create and initialize a temporary session that uses a new or
existing PST file
set TempSession = CreateObject("Redemption.RDOSession")
TempSession.LogonPstStore "c:\temp\archive_test.pst", 1, "Archive PST
Store"
'delete all folders in the temporary PST store to make sure there is
no collision
set ArchiveRootFolder = TempSession.Stores.DefaultStore.IPMRootFolder
set SubFolders = ArchiveRootFolder.Folders
for i = SubFolders.Count to 1 step - 1
SubFolders.Remove(i)
next
'copy the contents of the default store used by the first session
'to the PST file used by the second session
for each Folder in Session.Stores.DefaultStore.IPMRootFolder.Folders
Folder.CopyTo(ArchiveRootFolder)
next
|
GetCachedSharedDefaultFolder
|
Unlike GetSharedDefaultFolder,
returns only a cached
RDOFolder object. If the folder from the
given user is not cached, MAPI_E_NOT_FOUND exception is thrown.
NameOrAddressOrObject
- can be a string representing the Exchange mailbox name or address or
an RDOAddressEntry or an
RDORecipient object.
FolderType - integer.
The type of the folder. Accepts the same values as
Namespace.GetDefaultFolder method in Outlook Object Model (olFolderInbox,
olFolderContacts, etc).
Returns
a cached
RDOFolder object. If the folder cannot be
opened
|
//try to open a cached delegate Inbox first
//if that fails, try to open the online version
string mailboxName =
"Redemption Support";
RDOFolder folder =
null;
try
{
folder = session.GetCachedSharedDefaultFolder(mailboxName,
rdoDefaultFolders.olFolderInbox);
}
catch(COMException e)
{
if (e.ErrorCode != (int)MAPICode.MAPI_E_NOT_FOUND)
throw;
else
{
//could not find the cached folder, try its online version
folder = session.GetSharedDefaultFolder(mailboxName,
rdoDefaultFolders.olFolderInbox);
}
}
RDOItems items = folder.Items;
MessageBox.Show(items.Count.ToString());
Marshal.ReleaseComObject(items);
Marshal.ReleaseComObject(folder);
|
GetCachedSharedMailbox
|
Returns
RDOStore object representing the given user's
mailbox. Unlike GetSharedMailbox
, returns only a cached
RDOStore object. If the mailbox of the the
given user is not cached, MAPI_E_NOT_FOUND exception is thrown.
NameOrAddressOrObject - can be a string representing the Exchange
mailbox name or address or an
RDOAddressEntry or an RDORecipient object.
|
|
GetAutodiscoverXml(SMTPAddress, UserName, Password)
|
SMTPAddress - string. The SMTP address of an Exchange
mailbox for which autodiscover XML is to be retreiveed.
UserName - string, optional. Use ranem to be used for
authentication when retrieving autodiscover. If not specified,
Redemption attempts to use the identity of the current local user.
Password - string, optional
RDOSession.CacheAutodiscoverXml and
RDOSession.GetAutodiscoverXml
methods allow to cache autodiscover XML instead of retrieving it each
time it is needed. This allows to speed up Redemption methods that require
autodiscover, such as RDOSession.LogonHostedExchangeMailbox,
RDOSession.GetArchiveMailbox, ,
RDOSession.GetSharedMailbox,
RDOOutOfOfficeAssistant,
|
|
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. |
set Session =
CreateObject("Redemption.RDOSession")
Session.Logon
set Inbox = Session.GetDefaultFolder(olFolderInbox)
for each Msg in Inbox.Items
Debug.Print(Msg.Subject)
next |
GetFolderFromPath(FolderPath) |
Returns an RDOFolder object given its full path, e.g. "\\Personal
Folders\Inbox". Note that a folder path (unlike the entry id)
is not guaranteed to be unique, e.g. you can have multiple stores called
"Personal Folders", in which case GetFolderFromPath can fail.
FolderPath - string, full folder path in the form "\\Store
name\Parent Folder Name\Folder". If store name is not specified,
the default store is assumed. |
|
GetMessageFromMsgFile(FileName,
CreateNew) |
Returns an
RDOMail object
created on top of a specified MSG file.
FileName - string. A
fully qualified path to the MSG file (e.g. "c:\temp\test.msg").
CreateNew - Boolean,
optional (default value is false). Determines whether RDO opens an
existing file (an error will be raised if the file does not exist) or
creates a new MSG file. |
'open an existing MSG file
set Session =
CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set Msg = Session.GetMessageFromMsgFile("c:\temp\temp.msg")
msg.Display
'create a new MSG file
set Session =
CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set Msg = Session.GetMessageFromMsgFile("c:\temp\new.msg", true)
Msg.MessageClass = "IPM.Note"
Msg.Body = "new body"
Msg.Save
Msg.Display
|
GetSelectFoldersDialog |
Returns RDOSelectFoldersDialog
object that allows to display the "Select Folder" dialog and allows to
customize the dialog in the ways not possible through the
RDOSesion.PickFolder method call.
|
set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set SelectFoldersDialog = Session.GetSelectFoldersDialog
if SelectFoldersDialog.Display Then
set Folder = SelectFoldersDialog.SelectedFolder
MsgBox "selected folder: " & Folder.Name
End If
|
CreateMessageFromMsgFile(FileName,
MessageType, FileFormat) |
Creates a new MSG file and
returns a message (RDOMail or one of the
derived types, such as RDOContactItem)
created on top of MSG file.
Unlike
RDOSession.GetMessageFromMsgFile
(which can also create a new MSG file if CreateNew parameter = true),
you can specify the MSG file format (default, Unicode or ANSI) and the
message class of the new item so you always get back the right item kind
rather than the generic RDOMail.
FileName - string. A
fully qualified path to the MSG file (e.g. "c:\temp\test.msg").
MessageType - variant,
optional. Either string specifying the message class (e.g. "IPM.Contact")
or one of the rdoItemType values (integer), e.g. olPostItem.
If not specified, "IPM.Note"
will be used
FileFormat - variant,
optional (defaults to mffDefault) , one of the rdoMsgFileFormat enums:
mffDefault = 1 - Unicode
under Outlook 2007 or higher, ANSI otherwise
mffUnicode =2 - Unicode MSG file
mffANSI =3 - ANSI MSG file (Outlook 2002 and below)
|
'Create a contact (can be
any other type of item) on top of a new MSG file
'Below we will get back a contact since we explicitly specify the
message class ("IPM.Contact").
'The MSG file will be created in the Unicode format fro Outlook 2003 or
higher or ANSI format
'for the older versions of Outlook (mffDefault = 1)
'The last two parameters are optional
set Session = CreateObject("Redemption.RDOSession")
Session.Logon
'don't really need to call this
method
set Contact = Session.CreateMessageFromMsgFile("c:\temp\TestContact.Msg",
"IPM.Contact", 1)
Contact.FirstName = "Dmitry"
Contact.LastName = "Streblechenko"
Contact.EMail1Address = "redemption@dimastr.com"
Contact.Save
|
GetMessageFromID(EntryIDMessage,
EntryIDStore, Flags) |
EntryIDMessage -
string representing the entry id of the message
EntryIDStore - (optional). string representing the entry id of
the message's parent store.
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.
|
'using RDO along with the
Outlook Object Model 'connect to the same MAPI session as the one used by Outlook
'and open the given Outlook.MailItem object as
'Redemption.RDOMail
set Session =
CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set Mail = Session.GetMessageFromID(MailItem.EntryID)
MsgBox Mail.SenderName
|
GetFolderFromID(EntryIDFolder,
EntryIDStore, Flags) |
EntryIDFolder - string
representing the entry id of the folder
EntryIDStore - (optional). string representing the entry id of
the folder's parent store.
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.
|
'using RDO along with the
Outlook Object Model 'connect to the same MAPI session as the one used by Outlook
'and open the given Outlook.MAPIFolder object as
'Redemption.RDOFolder
set Session =
CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set Folder = Session.GetFolderFromID(MAPIFolder.EntryID)
for each Msg in Folder.Items
Debug.Print(Msg.Subject)
next |
GetSelectNamesDialog
|
Returns RDOSelectNamesDialog
object which can be used to display the contents of the address book.
|
set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set ABDialog = Session.GetSelectNamesDialog
ABDialog.ActiveRecipientSelector = olBCC
set Contacts = Session.GetDefaultFolder(olFolderContacts)
if (not (Contacts Is Nothing)) and (Contacts.ShowAsOutlookAB) Then
ABDialog.InitialAddressList = Contacts.GetAddressList
End If
ABDialog.ShowOnlyInitialAddressList = True
if ABDialog.Display Then
for each recip in ABDialog.Recipients
Debug.Print recip.Name & ": " &
recip.Address
next
End If
|
GetStoreFromID(EntryIDStore,
Flags) |
EntryIDStore - string
representing the entry id of the store.
Flags - (optional). integer flags to be used to call
IMAPISession::OpenMsgStore. 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 MDB_ONLINE(0x100) + MAPI_BEST_ACCESS
(0x10) will open the store in the best access mode bypassing the cached
store. Returns
RDOStore object. |
'using RDO along with the
Outlook Object Model'connect to the same MAPI session as the one used by Outlook
'and open the parent store of the given Outlook.MAPIFolder object as
'Redemption.RDOStore
set Session =
CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set Store = Session.GetStoreFromID(MAPIFolder.StoreID)
MsgBox Store.Name
|
GetAddressEntryFromID(EntryID,
Flags) |
EntryID - string
representing the entry id of the address entry object.
Flags - (optional). integer flags to be used to call
IAddrBook::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 address entry in the best access
mode bypassing the cached store.
Returns RDOAddressEntry object.
For the one-off entry ids (e.g. created using RDOSession.CreateOneOffEntryID),
this methods does not require an active MAPI session.
|
|
GetAddressListFromID(EntryID,
Flags) |
EntryID - string
representing the entry id of the address list object.
Flags - (optional). integer flags to be used to call
IAddrBook::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 address list in the best access
mode bypassing the cached store.
Returns RDOAddressList object.
|
|
GetSharedDefaultFolder(NameOrAddressOrObject,
FolderType) |
NameOrAddressOrObject
- can be a string representing the Exchange mailbox name or address or
an RDOAddressEntry or an
RDORecipient object.
FolderType - integer.
The type of the folder. Accepts the same values as
Namespace.GetDefaultFolder method in Outlook Object Model (olFolderInbox,
olFolderContacts, etc).
Returns
RDOFolder object. |
set Session =
CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set Folder = Session.GetSharedDefaultFolder("dmitry", olFolderCalendar)
for each Msg in Folder.Items
Debug.Print(Msg.Subject)
next |
GetSharedMailbox(NameOrAddressOrObject) |
Returns
RDOStore object representing the given user's
mailbox.
NameOrAddressOrObject - can be a string representing the Exchange
mailbox name or address or an
RDOAddressEntry or an RDORecipient object. |
set Session =
CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set Store = Session.GetSharedMailbox("dmitry")
MsgBox "The address of the
mailbox owner: " & Store.Owner.Address
|
GetSharedMailboxEx (NameOrAddressOrObject,
EntryIDFlags, OpenStoreFlags)
|
Returns
IRDOExchangeStore object representing the given user's
mailbox. Similar to GetSharedMailbox,
but allows to provide various flags used when creating the store entry
id (use Admin privilege etc) and opening the store.
NameOrAddressOrObject - can be a string representing the Exchange
mailbox name or address or an
RDOAddressEntry or an RDORecipient object.
EntryIDFlags - a combination of rdoCreateStoreEntryIDFlags enums
(see below). GetSharedMailbox method uses OPENSTORE_HOME_LOGON |
OPENSTORE_TAKE_OWNERSHIP.
OPENSTORE_USE_ADMIN_PRIVILEGE
(0x00000001)
OPENSTORE_PUBLIC (0x00000002)
OPENSTORE_HOME_LOGON (0x00000004)
OPENSTORE_TAKE_OWNERSHIP (0x00000008)
OPENSTORE_OVERRIDE_HOME_MDB (0x00000010)
OPENSTORE_TRANSPORT (0x00000020)
OPENSTORE_REMOTE_TRANSPORT (0x00000040)
OPENSTORE_INTERNET_ANONYMOUS (0x00000080)
OPENSTORE_ALTERNATE_SERVER (0x00000100)
OPENSTORE_IGNORE_HOME_MDB (0x00000200)
OPENSTORE_NO_MAIL (0x00000400)
OPENSTORE_OVERRIDE_LAST_MODIFIER (0x00000800)
OPENSTORE_CALLBACK_LOGON (0x00001000)
OPENSTORE_LOCAL (0x00002000)
OPENSTORE_FAIL_IF_NO_MAILBOX (0x00004000)
OPENSTORE_CACHE_EXCHANGE (0x00008000)
OPENSTORE_CLI_WITH_NAMEDPROP_FIX (0x00010000)
OPENSTORE_ENABLE_LAZY_LOGGING (0x00020000)
OPENSTORE_CLI_WITH_REPLID_GUID_MAPPING_FIX (0x00040000)
OPENSTORE_NO_LOCALIZATION (0x00080000)
OPENSTORE_RESTORE_DATABASE (0x00100000)
OPENSTORE_XFOREST_MOVE (0x00200000)
OpenStoreFlags- flags
to be used when calling IMAPISession::OpenMsgStore. GetSharedMailbox
method uses MDB_NO_DIALOG | MAPI_BEST_ACCESS | MDB_TEMPORARY |
MDB_NO_MAIL.
|
|
GetArchiveMailbox
(NameOrAddressOrObject,
EntryIDFlags, OpenStoreFlags)
|
Returns
IRDOExchangeStore object representing the given user's
archive mailbox (Exchange 2010 or newer only)
NameOrAddressOrObject - can be a string representing the Exchange
mailbox name or address or an
RDOAddressEntry or an RDORecipient object.
EntryIDFlags - Optional, variant. A combination of rdoCreateStoreEntryIDFlags enums
(see GetSharedMailboxEx above). If not specified,
OPENSTORE_HOME_LOGON | OPENSTORE_TAKE_OWNERSHIP are used.
OpenStoreFlags-
Optional, variant. Flags
to be used when calling IMAPISession::OpenMsgStore.
(see GetSharedMailboxEx above) If not specified,
MDB_NO_DIALOG | MAPI_BEST_ACCESS | MDB_TEMPORARY | MDB_NO_MAIL are used.
|
set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set AddressEntry = Session.CurrentUser
set ArchiveStore = Session.GetArchiveMailbox(AddressEntry)
for each fld in ArchiveStore.IPMRootFolder.Folders
Debug.Print fld.Name
next
|
GetNicknames(ProfileOrFileName)
|
Returns
RDONickNames collection representing
nicknames from a particular profile, file or message store.
This method does not require
an active MAPI session.
ProfileOrFileName -
variant, optional. Either a string (profile name of file name) or an
RDOStore object.
If not specified, and there
is no active MAPI session (i.e. you did not call Logon or set the
MAPIOBJECT property), will return the nick names for the default
profile. If there is an active session, the nicknames form the current
profile will be returned.
If specified, Redemption will
check if the profile with the given name exists (see example) and return
nicknames for that profile.
If the profile with the given
name does not exist, Redemption assumes that a fully qualified file name
is specified (e.g. "C:\temp\Nicknames.NK2") and will attempt to open the
file.
If an
RDOStore object is passed, GetNicknames
will attempt to retrieve the nicknames stored in a hidden item in the
Inbox of the specified store.
If neither profile nor file
exist, or the no store is specified, an error will be raised.
|
'list all nicknames in all
profiles
set Session = CreateObject("Redemption.RDOSession")
for each ProfileName in Session.Profiles
Debug.Print("-----------------------------")
Debug.Print("--- " & ProfileName & " --- ")
Debug.Print("-----------------------------")
set NickNames = Session.GetNickNames(ProfileName)
for each NickName in NickNames
Debug.Print NickName.Name & " - " &
NickName.SmtpAddress
next
next
|
GetRDOObjectFromOutlookObject (OutlookObject, Unwrap)
|
Returns RDO Object (RDOMail, RDOFolder, etc) form the corresponding
Outlook Object Model object.
Normally, to retrieve an RDO object from an Outlook object, it is
necessary to call
RDOSession.GetMessageFromID.
That call however opens another instance of the message, and if
modifications are made to both objects, can produce an conflict error.
GetRDOObjectFromOutlookObject method will use the MAPIOBJECT
property exposed by the Outlook objects in the same manner used by the
Safe*Item objects.
OutlookObject - object. The following objects are
supported: messages (MailItem, ContactItem, etc), MAPIFolder,
AddressEntry, Store, Attachment).
Unwrap - optional, boolean. If true, for messages,
Redemption will use
IMAPISecureMessage.GetBaseMessage.
For the stores,
IProxyStoreObject will be used.
|
set Session = CreateObject("Redemption.RDOSession")
set Msg = session.GetRDOObjectFromOutlookObject(Application.ActiveInspector.CurrentItem,
true)
MsgBox Msg.SaveAs "c:\temp\test.msg",
olMsg
|
GetWindowsUser(Name, NameKind) |
Returns an
RDOAddressEntry object corresponding to
the specified name, which can be a display name, primary SMTP address,
NT style user name (domain\user), etc. GetWindowsUser
(just like RDOSession.CurrentWindowsUser)
does not require an active MAPI session and can be called without
calling Logon or LogonExchangeMailbox.
Name - string. Name to be resolved
NameKind - one of the rdoWindowsUserNameKind enum
values:
ADS_NAME_TYPE_1779 =1
ADS_NAME_TYPE_CANONICAL = 2
ADS_NAME_TYPE_NT4 = 3
ADS_NAME_TYPE_DISPLAY = 4
ADS_NAME_TYPE_DOMAIN_SIMPLE =5
ADS_NAME_TYPE_ENTERPRISE_SIMPLE =6
ADS_NAME_TYPE_GUID = 7
ADS_NAME_TYPE_UNKNOWN = 8
ADS_NAME_TYPE_USER_PRINCIPAL_NAME = 9
ADS_NAME_TYPE_CANONICAL_EX = 10
ADS_NAME_TYPE_SERVICE_PRINCIPAL_NAME = 11
ADS_NAME_TYPE_SID_OR_SID_HISTORY_NAME = 12
|
ADS_NAME_TYPE_NT4 = 3
ADS_NAME_TYPE_DISPLAY = 4
ADS_NAME_TYPE_USER_PRINCIPAL_NAME = 9
set Session = CreateObject("Redemption.RDOSession")
set AddressEntry = Session.GetWindowsUser("LITWAREINC\Bob",
ADS_NAME_TYPE_NT4)
MsgBox AddressEntry.Name & ": " & AddressEntry.SmtpAddress
|
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 |
|
OpenRulesFile(FileName)
|
Opens an RWZ file with the specified filename and returns an instance of
the RDOClientRules object.
Dos not require an active MAPI session.
FileName - string, a fully qualified RWZ filename.
|
set Session = CreateObject("Redemption.RDOSession")
set rules = Session.OpenRulesFile("c:\temp\test.rwz")
for
each ClientRule
in rules
Debug.Print
ClientRule.Name
next
|
SetLocaleIDs(LocaleID,
CodePageID) |
The SetLocaleIDs
method sets identifiers that define a messaging users locale.
The locale info is only used
by the dynamically created profiles when LogonExchangeMailbox is
called. If SetLocaleIDs is called after logon, an error will be
raised.
LocaleID - integer.
The locale identifier (LCID) to be used for
this messaging user.
CodePageID - integer.
The code page identifier to be used for this
messaging user.
|
set Session =
CreateObject("Redemption.RDOSession")
Session.SetLocaleIDs 1031, 1252
'German locale with
multilingual codepage
Session.LogonExchangeMailbox "dmitry", "vm-w2k3"
|
PickFolder(SelectedFolder,
Caption, ParentWindow, Flags, AllowedFolderType) |
Displays the Pick Folder
dialog box. This is a modal dialog box which means that code execution
will not continue until the user either selects a folder or cancels the
dialog box. Returns an
RDOFolder object corresponding to the folder
that the user selects in the dialog box. Returns Nothing when the dialog
box is canceled by the user.
SelectedFolder -
optional,
RDOFolder. If specified, this folder will be
initially selected. If not specified, the Inbox folder is selected when
the dialog is displayed.
Caption - optional,
string. If specified, determines the Select Folder dialog caption. If
not specified, defaults to "Select Folder" (localized
appropriately in French/German/Italian/Portugese/Russian/Spanish along
with other dialog box controls).
ParentWindow -
optional, integer. If specified, the handle of the dialog's parent
window. If not specified, the dialog is shown as a child of the
currently active window.
Flags - optional. Can
be a combination of the following rdoPickFolderFlags enum values:
sffHideNewButton (1) -
hides the "New" button, preventing the user from creating a new folder.
pffHideParentFolders (2) - displays only the specified folders
and its subfolders (see the screenshot)
pffNoSizing (4) - prevents the user from resizing the dialog.
pffHidePublicFoldersStore
(8) - hides the Public Folders store but leaves all the other stores
visible (unless pffHideParentFolders is also specified).
pffShowStoresOnly
(16) - only shows the top level folders of the stores in the current
profile. "New" button will be hidden.
AllowedFolderType - optional. One of the rdoItemType enums. If
not specified, all folders are displayed. If is specified, only the
folders with the DefaultItemType property matching the specified value
are displayed.
The following
values are supported: olMailItem, olAppointmentItem, olContactItem,
olTaskItem, olJournalItem, olNoteItem. |
set Session =
CreateObject("Redemption.RDOSession")
Session.Logon
set Folder = Session.PickFolder
If Not (Folder Is Nothing)
Then
MsgBox
"You selected " & Folder.Name
End If
![](PickFolder1.jpg)
'Allows to select either
the Contacts folder or one of its subfolders
sffHideNewButton = 1
sffHideParentFolders = 2
sffNoSizing = 4
set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set InitialFolder = Session.GetDefaultFolder(olFolderContacts)
set Folder = Session.PickFolder(InitialFolder, "Please select a contacts
folder", ,ffHideParentFolders)
![](PickFolder2.jpg)
'replacement for
Namespace.PickFolder in OOM
'that allows to specify the initial folder
set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
'convert Outlook.Folder to Redemption.RDOFolder
set rFolder =
Session.GetFolderFromID(Application.ActiveExplorer.CurrentFolder.EntryID)
set rFolder = Session.PickFolder(Folder, "Please select a folder")
if Not (rFolder Is Nothing) Then
'convert Redemption.RDOFolder back to Outlook.Folder
set oFolder =
Application.Session.GetFolderFromID(rFolder.EntryID)
MsgBox oFolder.Name
End If |
DoFastShutdown |
Shuts down MAPI in the
current process space. No MAPI calls will be allowed if this method
succeeds.
An error will be raised if
the current version of Outlook and all providers in the profile do not
support fast shutdown.
Only Outlook 2007 SP2 or
higher supports fast shutdown.
See the following for more
information:
http://blogs.msdn.com/stephen_griffin/archive/2009/03/03/fastest-shutdown-in-the-west.aspx
|
set Session =
CreateObject("Redemption.RDOSession")
Session.Logon
Debug.Print "Stores in the profile: " & Session.Stores.Count
if Session.FastShutdownSupported Then
Session.DoFastShutdown
Else
Session.Logoff
End If
|
|
Events: |
|
OnNewMail(EntryID) |
Fires when a new message is
delivered to the Inbox of the default 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 Session As
Redemption.RDOSession
...
Sub Session_OnNewMail(ByVal
EntryID As String)
Dim Msg As Redemption.RDOMail
Set Msg = Session.GetMessageFromID(EntryID)
MsgBox "Session_OnNewMail: " & Msg.Subject
End Sub |
OnOfflineStateChange |
Fires when the user clicks on the "Work Offline" button/menu item in
Outlook or when the RDOSession.Offline
property is set.
|
|