Safe* Redemption Objects
Use Safe* wrappers alongside existing Outlook Object Model code when you need minimal changes for security-prompted or object-model-limited properties.
Redemption has two main object families: Safe*Item wrappers for existing Outlook item code, and Redemption Data Objects for broader Outlook, Exchange, and MAPI access. Safe*Item objects can still wrap legacy CDO 1.21 objects, but new work should usually start with the Outlook Object Model or RDO.
Using Safe* Redemption Objects
Redemption is a regular COM object. Once registered, it is accessible to any programming language, including VB, VBA, VB.NET, C#, VC++, and Delphi. Safe*Item wrappers use Redemption's lower-level access to expose functionality that the Outlook Object Model blocks or limits.
Most creatable Redemption objects have an Item property that must be set to an Outlook item. Once it is set, you can access the properties and methods available on the original Outlook item. Blocked properties and methods bypass the Outlook Object Model; unblocked calls are forwarded to the Outlook object assigned to Item.
Dim SafeContact, oContact
Set SafeContact = CreateObject("Redemption.SafeContactItem") 'Create an instance of Redemption.SafeContactItem
Set oContact = Application.Session.GetDefaultFolder(10).Items(1) 'Get a contact item from Outlook
SafeContact.Item = oContact 'Set Item to an Outlook contact item
MsgBox SafeContact.Email1Address 'Access Email1Address without warnings
There are matching objects for all Outlook items with blocked properties: SafeContactItem, SafeMailItem, SafeTaskItem, SafeJournalItem, SafeMeetingItem, and SafePostItem. Use the list on the left for the complete set of Safe* objects, properties, and methods handled directly by Redemption.
Minimal Code Changes
These examples show the same code before and after switching to a Safe* object. Highlighted lines are the changes needed to route blocked access through Redemption.
VBScript
Before
Dim Contact
Set Contact = Application.Session.GetDefaultFolder(10).Items(1)
MsgBox Contact.Email1Address 'Direct Outlook access can show a warning
'No code below is affected
After
Dim Contact, oContact
Set oContact = Application.Session.GetDefaultFolder(10).Items(1)
Set Contact = CreateObject("Redemption.SafeContactItem")
Contact.Item = oContact 'Never use Set when assigning Item
MsgBox Contact.Email1Address 'No warnings are shown
'No code below is affected
VB
Before
Dim Contact As Outlook.ContactItem
Set Contact = Application.Session.GetDefaultFolder(10).Items(1)
MsgBox Contact.Email1Address
'No code below is affected
After
Dim Contact As Object, oContact As Object
Set oContact = Application.Session.GetDefaultFolder(10).Items(1)
Set Contact = New Redemption.SafeContactItem
Contact.Item = oContact 'Never use Set when assigning Item
MsgBox Contact.Email1Address
'No code below is affected
C#
Before
Outlook.ContactItem contact =
Application.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts)
.Items.GetFirst();
MessageBox.Show(contact.Email1Address);
// No code below is affected
After
Outlook.ContactItem contact =
Application.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts)
.Items.GetFirst();
Redemption.SafeContactItem safeContact = new Redemption.SafeContactItem();
safeContact.Item = contact;
MessageBox.Show(safeContact.Email1Address);
// No code below is affected
In VB, declare the Safe* object as Object rather than the specific Outlook item type. Safe*Item objects expose the corresponding Outlook item members dynamically after the Outlook item is assigned to Item, so the compiler cannot see those members at design time.