security alert happens with this code running Redemption

J

Jim Spicer

Hi,
This is "old" code running some "new" Redemption functions. The
configuration is VB6, WinXP, OL2K3 and Redemption 3.3 distributable.

The code has two parts:
1. I use CDO and MAPI to get the folder names of contacts type folders.
2. Still logged onto the MAPI session, I use Outlook to enumerate the
folders. The new Redemption code functions along with the old but I get the
security alert.

I'm really new to Redemption and should probably spend more time on this
before coming to the group but I have some deadlines...

Code:

Dim oContactItems As Object
Dim oDistFolder As Object
Dim oContactItem As Object
Dim SafeContact As Object
Dim oOL As Object
Dim oNS As Object
Dim Utils As Redemption.MAPIUtils
On Error Resume Next
'this sets the list to enumerate
strFolder = Me.cbxListName.Text
Set oOL = CreateObject("outlook.application")
Set oNS = oOL.GetNamespace("MAPI")
Set SafeContact = New Redemption.SafeContactItem
Set Utils = CreateObject("Redemption.MAPIUtils")
Set oDistFolder =
oNS.GetDefaultFolder(olFolderInbox).Parent.Folders(strFolder)
Set oContactItems = oDistFolder.Items
SafeContact.Item = oContactItems 'assigns Outlook object to Redemption
object
For Each oContactItem In SafeContact.Item
If Not oContactItem.Email1Address = "" Then
If oContactItem.Email1AddressType = "EX" Then
strAddress = exAddrToSMTPAddr(objSession,
oContactItem.Email1Address)
Else
strAddress = oContactItem.Email1Address
End If
End If
Next

I've stripped out the app specific stuff.

I've tried to assign the oDistFolder to Redemption but couldn't make it
work.

Thanks for any help,
Jim Spicer
 
D

Dmitry Streblechenko \(MVP\)

You need to assign an instance of Outlook.ContactItem to
SafeContactItem.Item property, but you are assigning an instance of
Outlook.Items object.
Get rid of the

SafeContact.Item = oContactItems

line and rewrite the loop as

For Each oContactItem In oDistFolder.Items
SafeContact.Item = oContactItem
If Not SafeContact.Email1Address = "" Then
If SafeContact.Email1AddressType = "EX" Then
strAddress = exAddrToSMTPAddr(objSession,
SafeContact.Email1Address)
Else
strAddress = SafeContact.Email1Address
End If
End If
Next


Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
J

Jim Spicer

That did it. The documentation clearly states ...an Outlook item...I guess
that means one at a time. Is there any way to handle properties like .Count,
etc?

Thanks for the help,
Jim
 
D

Dmitry Streblechenko \(MVP\)

There is realy no reason to since Count etc properties are not blocked.
Safe*Item objects only expose blocked properties in only blocked modes. E.g.
reading MailItem.To is blocked, hence SafeMailItem implements reading the To
property. Writing is not blocked, so Redemption does not implement it. If
you dim your Safe*Item objects as generic Object to force late binding,
Redemption will be happy to dynamically forward the calls to the original
OOM object assigned to the Item property if it does not directly handle the
property/method.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
F

Falconetti Daniel

Thks,

content are different between system32\mapisv.inf and the one installed from
Outlook!

To avoïd problems I've decided to launch the appli from a client station and
it's Ok.

For my initial question here is the piece of code which make it
Dim......
Set objProfiles = CreateObject("ProfMan.Profiles")
Set objProfMan = objProfiles.Add(strMailbox, False, False)
Set ExchService = objProfMan.Services.Add("MSEMS", "Microsoft Exchange",
False)
Set ExchProperties = CreateObject("ProfMan.PropertyBag")
ExchProperties.Add PR_PROFILE_UNRESOLVED_SERVER, strExServeur
ExchProperties.Add PR_PROFILE_UNRESOLVED_NAME, strMailbox
ExchService.Configure uiNever, , ExchProperties
Set CABService = objProfMan.Services.Add("CONTAB", "Carnet d'adresse
Outlook", False)
Set CABProperties = CreateObject("ProfMan.PropertyBag") 'Don't know
if it's necessary haven't tested it without yet!
CABService.Configure uiNever, , CABProperties

Set ExchService = Nothing
Set ExchProperties = Nothing
Set CABService = Nothing
Set CABProperties = Nothing


Set olSession = CreateObject("outlook.Application") 'olSession
est en fait un objet application (olApp)
Set olNS = olSession.GetNamespace("MAPI")
olNS.Logon Profile:=strMailbox, showDialog:=False, NewSession:=True
Set olContactFolder = olNS.GetDefaultFolder(olFolderContacts)
Tempo(5) ' That's a sub that wait for 5 seconds It allows
sufficiant time for the Contact folder to mount as an Outlook Address Book

Hope that will serve!
dmitry, you can add it to your site if you think it's worth it

Thk for your help
 
D

Dmitry Streblechenko \(MVP\)

Thanks Daniel. So if you add the CONTAB service, it automatically adds the
Contacts default folder to its list of folders available as address book
containers the first time you use that profile, right?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top