M
McKilty
I need to loop every Distribution List and get the names and SMTP
address of each member. Instead of the (e-mail address removed) I am
getting /o=SomeCompany/ou=Domain/cn=Recipients/cn=RJones.
How can I get the actual e-mail address?
The code I'm using:
Private Sub Command1_Click()
Dim objSession As MAPI.Session
Dim objAddrList As MAPI.AddressList
Dim objAddrEntries As MAPI.AddressEntries
Dim objAddrEntry As MAPI.AddressEntry
Dim objDistMembers As MAPI.AddressEntries
Dim objDistMember As MAPI.AddressEntry
Open "C:\DL.txt" For Output As #1
Set objSession = CreateObject("MAPI.Session")
objSession.Logon ("Outlook")
Set objAddrList = objSession.GetAddressList(CdoAddressListGAL)
'Move through the users and distribution lists in the PAB
Set objAddrEntries = objAddrList.AddressEntries
Set objAddrEntry = objAddrEntries.GetFirst
Do Until objAddrEntry Is Nothing
With objAddrEntry
Select Case .DisplayType
Case 1
'Move through the distribution list members
Set objDistMembers = .Members
Set objDistMember = objDistMembers.GetFirst
Print #1, objAddrEntry.Name
Do Until objDistMember Is Nothing '
Print #1, Chr(9) & objDistMember.Name & Chr(9) &
objDistMember.Address
Set objDistMember = objDistMembers.GetNext
Loop
End Select
End With
Set objAddrEntry = objAddrEntries.GetNext
Loop
Close #1
Set objDistMember = Nothing
Set objDistMembers = Nothing
Set objAddrEntries = Nothing
Set objAddrEntry = Nothing
Set objAddrList = Nothing
Set objSession = Nothing
End Sub
address of each member. Instead of the (e-mail address removed) I am
getting /o=SomeCompany/ou=Domain/cn=Recipients/cn=RJones.
How can I get the actual e-mail address?
The code I'm using:
Private Sub Command1_Click()
Dim objSession As MAPI.Session
Dim objAddrList As MAPI.AddressList
Dim objAddrEntries As MAPI.AddressEntries
Dim objAddrEntry As MAPI.AddressEntry
Dim objDistMembers As MAPI.AddressEntries
Dim objDistMember As MAPI.AddressEntry
Open "C:\DL.txt" For Output As #1
Set objSession = CreateObject("MAPI.Session")
objSession.Logon ("Outlook")
Set objAddrList = objSession.GetAddressList(CdoAddressListGAL)
'Move through the users and distribution lists in the PAB
Set objAddrEntries = objAddrList.AddressEntries
Set objAddrEntry = objAddrEntries.GetFirst
Do Until objAddrEntry Is Nothing
With objAddrEntry
Select Case .DisplayType
Case 1
'Move through the distribution list members
Set objDistMembers = .Members
Set objDistMember = objDistMembers.GetFirst
Print #1, objAddrEntry.Name
Do Until objDistMember Is Nothing '
Print #1, Chr(9) & objDistMember.Name & Chr(9) &
objDistMember.Address
Set objDistMember = objDistMembers.GetNext
Loop
End Select
End With
Set objAddrEntry = objAddrEntries.GetNext
Loop
Close #1
Set objDistMember = Nothing
Set objDistMembers = Nothing
Set objAddrEntries = Nothing
Set objAddrEntry = Nothing
Set objAddrList = Nothing
Set objSession = Nothing
End Sub