hi,
iam trying to extract the members of a particular Distribution list from the Global Address list from outlook to excel.
this is the code i have tried so far, iam able to pull all the distribution lists but not a specific list...
Can someone help me with the syntax iam missing?? having trouble with lines in BOLD
sDLName = " Managers" 'Name of the distribution List
Set appOL = CreateObject("Outlook.Application")
Set oGAL = appOL.GetNameSpace("MAPI").AddressLists("All Distribution Lists").AddressEntries
Set oDL = oGAL(sDLName).Item
For i = 1 To oDL.Members.Count
Set oContact = oDL.Members.Item(i)
If oContact.AddressEntryUserType = 0 Then
Set oUser = oContact.GetExchangeUser
If Len(oUser.lastname) > 0 Then
UserIndex = UserIndex + 1
arrUsers(UserIndex, 1) = oUser.OfficeLocation
arrUsers(UserIndex, 2) = oUser.PrimarySMTPAddress
End If
End If
Next i
appOL.Quit
Merge the two lines highlighted in bold to one as below:
Set oGAL = appOL.GetNameSpace("MAPI").AddressLists("All Distribution Lists").AddressEntries.Item(sDLName)
Bookmarks