H
Henry Stockbridge
Hi,
I am attempting to obtain the names and e-mail addresses from members
of a Distribution List, but my code produces Error: 424 'Object
Required.' (See code below at === Error here ===> line.)
I am using Windows XP, Outlook 2003 and have set a reference to
Microsoft CDO 1.21 Library.
Any help you can lend would be appreciated.
- Henry
====================================================
Public Sub GetDistListInfo()
Dim cdosession As MAPI.Session
Dim cdoAddressLists As MAPI.AddressLists
Dim cdoAddresslist As MAPI.AddressList
Dim cdoaddressentries As MAPI.AddressEntries
Dim cdoaddressentry As MAPI.AddressEntry
Dim DistList As String
DistList = "DistributionListNameHere"
Set cdosession = New MAPI.Session
cdosession.Logon
Set cdoAddressLists = cdosession.AddressLists
Set cdoAddresslist = cdoAddressLists.Item("Global Address List")
Set cdoaddressentries = cdoAddresslist.AddressEntries
Set cdoaddressentry = cdoaddressentries.Item(DistList)
=== Error here ===> For Each cdoaddressentry In
cdoaddressentry.Members
Debug.Print cdoaddressentry.Name & ">" & _
Trim(Mid(cdoaddressentry.Address, _
(InStr(1, cdoaddressentry.Address, "Recipients/cn=") + 14), 100))
_
& ">" & DistList
Next
cdosession.Logoff
Set cdosession = Nothing
Set cdoAddressLists = Nothing
Set cdoAddresslist = Nothing
Set cdoaddressentries = Nothing
Set cdoaddressentry = Nothing
End Sub
=========================================
I am attempting to obtain the names and e-mail addresses from members
of a Distribution List, but my code produces Error: 424 'Object
Required.' (See code below at === Error here ===> line.)
I am using Windows XP, Outlook 2003 and have set a reference to
Microsoft CDO 1.21 Library.
Any help you can lend would be appreciated.
- Henry
====================================================
Public Sub GetDistListInfo()
Dim cdosession As MAPI.Session
Dim cdoAddressLists As MAPI.AddressLists
Dim cdoAddresslist As MAPI.AddressList
Dim cdoaddressentries As MAPI.AddressEntries
Dim cdoaddressentry As MAPI.AddressEntry
Dim DistList As String
DistList = "DistributionListNameHere"
Set cdosession = New MAPI.Session
cdosession.Logon
Set cdoAddressLists = cdosession.AddressLists
Set cdoAddresslist = cdoAddressLists.Item("Global Address List")
Set cdoaddressentries = cdoAddresslist.AddressEntries
Set cdoaddressentry = cdoaddressentries.Item(DistList)
=== Error here ===> For Each cdoaddressentry In
cdoaddressentry.Members
Debug.Print cdoaddressentry.Name & ">" & _
Trim(Mid(cdoaddressentry.Address, _
(InStr(1, cdoaddressentry.Address, "Recipients/cn=") + 14), 100))
_
& ">" & DistList
Next
cdosession.Logoff
Set cdosession = Nothing
Set cdoAddressLists = Nothing
Set cdoAddresslist = Nothing
Set cdoaddressentries = Nothing
Set cdoaddressentry = Nothing
End Sub
=========================================