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
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