Outlook Security Warnings

  • Thread starter Thread starter Ben Crinion
  • Start date Start date
B

Ben Crinion

Hi

I recently adjusted my code to use redemption rather than CDO to avoid
making users of my software intstall CDO but now im getting security
warnings from Outlook.

Here is the line which causes the warning.
Set objAddressEntries =
Application.Session.AddressLists.Item(3).AddressEntries

If I click no to not allow my program access to the Address Book it still
manages to get access and perform as expected but I dont want users to have
to click every time my app calls this function.

Am i using redemption correctly as i read somewhere that im not supposed to
dim objects as redemption.whatever as type mismatch errors occur? I just
dont understand.

Does anyone have any clues?

Thanks
Ben Crinion

Here is the full code of the fuction.
Public Function SearchGlobalAddressList_NONCDO(ByVal strPhoneNo As String)
As String

'table dims
MsgBox "Dims"
Dim Columns(1)
Dim Row
Dim Filter 'As Redemption.TableFilter
Dim Restr 'As Redemption.RestrictionProperty
Dim Table 'As Redemption.MAPITable

'address dims
'Dim objSession 'As session
Dim objAddressLists 'As Redemption.AddressLists
Dim objAddressList 'As Redemption.AddressList
Dim objAddressEntries As Redemption.AddressEntries


'Get Global Address List
'Set objAddressList = objSession.getaddresslist(CdoAddressListGAL)
MsgBox "set address lists"
Set objAddressLists = Application.Session.AddressLists
Debug.Print objAddressLists.Item(3).Name

MsgBox "set address list"
Set objAddressList = objAddressLists.Item(3)
'Obtain the entire list of contacts and distribution lists in the
address book.

MsgBox "set address entries"
'Set objAddressEntries = objAddressList.AddressEntries
..


'Here is the line which causes the warning.
Set objAddressEntries =
Application.Session.AddressLists.Item(3).AddressEntries



MsgBox "tickle"
'hex values for the fields i need
PR_DISPLAY_NAME = &H3001001E
PR_MOBILE_PHONE_NO = &H3A1C001E

'set the contents of the table to the the collection of address entries
MsgBox "create table"
Set Table = CreateObject("TBOLcom.MAPITable")

MsgBox "add entries to table"
Table.Item = objAddressEntries

MsgBox "1"
Columns(0) = PR_DISPLAY_NAME
Columns(1) = PR_MOBILE_PHONE_NO

MsgBox "2"
Table.Columns = Columns
Table.GoToFirst
Dim temp As String

Do
MsgBox "get row"
Row = Table.GetRow

If Not IsEmpty(Row) Then
On Error Resume Next
MsgBox "access table"
temp = StripNumber(Row(1))
If temp = strPhoneNo Then
MsgBox "return table data as string"
SearchGlobalAddressList_NONCDO = ("(" & Row(0) & ") " &
Row(1))
boolFoundContact = True
Exit Function
End If
End If
Loop Until IsEmpty(Row)

SearchGlobalAddressList_NONCDO = "-1"
End Function
 
Use Redemption's AddressEntries and AddressLists for that. Set the
Redemption AddressLists to the Outlook AddressLists collection and work in
Redemption from that point forward. That way you won't get the security
prompts.
 
Ken

Im still having a problem with this particular issue. if i declare the
AddressLists and AddressEntries explicitly as Redemption.blah it gives a
type mismatch, if i dont i get security warnings.

Im very confused by this issue now as i thought that i had fixed it once
then when i came to test it again later it didnt work.

Please could you demonstrate exactly what you meant.

Thanks
 
Dmitry

The code is contained in the first pist of this group and also at the bottom
of this message.

Thanks
 
I have tried defining the variables bellow in various different ways by
either commenting out everything after the "As"

Dim objAddressLists As Redemption.AddressLists
Dim objAddressList As Redemption.AddressList
Dim objAddressEntries As Redemption.AddressEntries

Here is the most recent code.

Public Function SearchGlobalAddressList_NONCDO(ByVal strPhoneNo As String)
As String

Dim Columns(1)
Dim Row
Dim Filter 'As Redemption.TableFilter
Dim Restr 'As Redemption.RestrictionProperty
Dim Table 'As Redemption.MAPITable

'address dims
Dim objSession 'As session
Dim objAddressLists As Redemption.AddressLists
Dim objAddressList As Redemption.AddressList
Dim objAddressEntries As Redemption.AddressEntries


'Get Global Address List
'Set objAddressList = objSession.getaddresslist(CdoAddressListGAL)
Set objAddressLists = Application.session.AddressLists
Debug.Print objAddressLists.Item(3).Name

Set objAddressList = objAddressLists.Item(3)
'Obtain the entire list of contacts and distribution lists in the
address book.
Set objAddressEntries = objAddressList.AddressEntries

'hex values for the fields i need
PR_DISPLAY_NAME = &H3001001E
PR_MOBILE_PHONE_NO = &H3A1C001E

'set the contents of the table to the the collection of address entries
Set Table = CreateObject("TBOLcom.MAPITable")

Table.Item = objAddressEntries

Columns(0) = PR_DISPLAY_NAME
Columns(1) = PR_MOBILE_PHONE_NO

Table.Columns = Columns
Table.GoToFirst
Dim temp As String

Do
Row = Table.GetRow

If Not IsEmpty(Row) Then
On Error Resume Next
temp = StripNumber(Row(1))
If temp = strPhoneNo Then
SearchGlobalAddressList_NONCDO = ("(" & Row(0) & ") " &
Row(1))
boolFoundContact = True
Exit Function
End If
End If
Loop Until IsEmpty(Row)

SearchGlobalAddressList_NONCDO = "-1"
End Function
 
You only declare the variables as Redemption.xxx, but you assign them to CDO
objects, hence you get the type mismatch.
Create an instance of the Redemption.AddressLists object instead and go from
there - it is very close in functionality to the Namespace.AddressLists in
OOM and Session.AddressLists in CDO 1.21.

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