Getting SMTP from Distribution List Members

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
 
D

Dmitry Streblechenko

That *is* the actual e-mail address, but its type happens to be "EX", not
"SMTP".
You will need to read the PR_EMS_AB_PROXY_ADDRESSES property using
objAddrEntry.Fields[].

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

McKilty

That *is* the actual e-mail address, but its type happens to be "EX", not
"SMTP".
You will need to read the PR_EMS_AB_PROXY_ADDRESSES property using
objAddrEntry.Fields[].

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

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
Set objDistMember = Nothing
Set objDistMembers = Nothing
Set objAddrEntries = Nothing
Set objAddrEntry = Nothing
Set objAddrList = Nothing
Set objSession = Nothing

Yeah, I figured I would be using the wrong terminology. Looking at my
code, is it simple to incorporate that code? I'm going to give it a
shot, but I'm pretty rusty...
 
D

Dmitry Streblechenko

strAddress = objDistMember.Address

PR_EMS_AB_PROXY_ADDRESSES = &H800F101E

ProxyAddresses = objDistMember.Fields(PR_EMS_AB_PROXY_ADDRESSES)


For i = LBound(ProxyAddresses) To UBound(ProxyAddresses)

If Left(ProxyAddresses(i), 5) = "SMTP:" Then

strAddress = Right(ProxyAddresses(i), Len(ProxyAddresses(i)) - 5)

Exit For

End If

Next


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

Dmitry Streblechenko

strAddress = objDistMember.Address

PR_EMS_AB_PROXY_ADDRESSES = &H800F101E

ProxyAddresses = objDistMember.Fields(PR_EMS_AB_PROXY_ADDRESSES)


For i = LBound(ProxyAddresses) To UBound(ProxyAddresses)

If Left(ProxyAddresses(i), 5) = "SMTP:" Then

strAddress = Right(ProxyAddresses(i), Len(ProxyAddresses(i)) - 5)

Exit For

End If

Next


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

Dmitry Streblechenko

strAddress = objDistMember.Address

PR_EMS_AB_PROXY_ADDRESSES = &H800F101E

ProxyAddresses = objDistMember.Fields(PR_EMS_AB_PROXY_ADDRESSES)


For i = LBound(ProxyAddresses) To UBound(ProxyAddresses)

If Left(ProxyAddresses(i), 5) = "SMTP:" Then

strAddress = Right(ProxyAddresses(i), Len(ProxyAddresses(i)) - 5)

Exit For

End If

Next


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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top