CDO MAPI Session failing to retrieve user name but Getexchage user

  • Thread starter Thread starter paresh
  • Start date Start date
P

paresh

Hi, could anyone please tell me why attached CDO method is failing on some
computer to retrieve users list from my Outlook 2007 add-in? If gives it
says "Activax component cant create object".

The GetExchangeMethod always works but it is slower than CDO.

Any help would be really helpful.

Thanks.

Using CDO:

Dim cdoSession As Object
Dim cdoAddressList As Object
Dim cdoAddressEntries As Object
Dim cdoAddressEntry As Object
' --------------------------------------------------------------
' Create MAPI session and logged into it
' --------------------------------------------------------------
Set cdoSession = CreateObject("MAPI.Session")
cdoSession.Logon "", "", False, False, 0

' --------------------------------------------------------------
' Get all users address list
' --------------------------------------------------------------
Set cdoAddressList = cdoSession.AddressLists.Item("All Users")

' --------------------------------------------------------------
' Get address entries of the global address list
' --------------------------------------------------------------
Set cdoAddressEntries = cdoAddressList.AddressEntries
i = 1

' --------------------------------------------------------------
' Loop through the address entries collection and
' Add each address entry to the static array
' --------------------------------------------------------------
For Each cdoAddressEntry In cdoAddressEntries
ReDim Preserve allUsers(1 To i + 1) As String
allUsers(i) = cdoAddressEntry.Name
i = i + 1
Next

' --------------------------------------------------------------
' objects clean up
' --------------------------------------------------------------
Set cdoAddressList = Nothing
Set cdoAddressEntries = Nothing
Set cdoAddressEntry = Nothing

' --------------------------------------------------------------
' Logoff from MAPI Session
' --------------------------------------------------------------
cdoSession.Logoff
Set cdoSession = Nothing

Using GetExchangeUser method:

Dim i As Integer

i = 1

Dim oEntry As Outlook.AddressEntry

For i = 1 To usersList.Count
Set oEntry = usersList.Item(i)
ReDim Preserve allUsers(1 To i + 1) As String
allUsers(i) = oEntry.GetExchangeUser().Name
i = i + 1
Next
 
The most likely reason is that CDO is not installed on the machine. Outlook
2007 doesn't include CDO. You have to download and install it on each
machine that needs it.
 
The most likely explanation is that CDO is not present on the machine. It's
not part of Outlook and has to be downloaded and installed on every machine
where you want to use it.
 
Back
Top