Question : Outlook Distribution Lists

I have a distribution list in Microsoft Outlook 2003 with many names on it.  I'd like to extract the city and state of each person from the properties of each name.  However, I can't seem to display additional columns for each name.  Is there a way I can use VBA to extract certain info from the properties of each person?

I can create a text file of the names from the file menu of the Distribution list.  I'd like to read the names into a VBA routine and look up some other information about them

Answer : Outlook Distribution Lists

Hi, dugutigi.

This will do it.  I don't know how you want to select the distribution list, which city and state you want (a contact has several of them), nor what you want to do with the information once found.  You can modify the code to meet your needs or provide those details and I'll modify the code for you.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
Sub GetDLinfo()
    Dim olkDL As Outlook.DistListItem, _
        olkEntry As Outlook.Recipient, _
        olkContact As Outlook.contactItem, _
        intCount As Integer, _
        strAddress As String
    'Get the currently selected distribution list'
    Set olkDL = Application.ActiveExplorer.Selection(1)
    For intCount = 1 To olkDL.MemberCount
        Set olkEntry = olkDL.GetMember(intCount)
        strAddress = olkEntry.AddressEntry.Address
        Set olkContact = Session.GetDefaultFolder(olFolderContacts).Items.Find("[Email1Address] = '" & strAddress & "' OR [Email2Address] = '" & strAddress & "' OR [Email3Address] = '" & strAddress & "'")
        If TypeName(olkContact) = "Nothing" Then
            Debug.Print "Not found: " & strAddress
        Else
            Debug.Print olkContact.BusinessAddressCity & ", " & olkContact.BusinessAddressState
        End If
    Next
    Set olkEntry = Nothing
    Set olkDL = Nothing
End Sub
Random Solutions  
 
programming4us programming4us