Results 1 to 6 of 6
  1. #1
    4 Star Lounger
    Join Date
    Aug 2003
    Location
    Stroud, United Kingdom
    Posts
    548
    Thanks
    0
    Thanked 0 Times in 0 Posts

    DistributionList Details (2000)

    Hi,

    I have a distribution list with a lot of members, and was wondering if there was a way in VB to loop through the contacts in the list and mark them all as belonging to a category, so then i can filter out the contacts and export all their details.

    thanks
    Thanks,

    pmatz

  2. #2
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: DistributionList Details (2000)

    There is some code to loop through a DistList <!post=here,323204>here<!/post>. In a brief search I didn't see any code to get the source Contact resolved, you can probably use the Find Method to search the Contact Folder for .FullName.
    -John ... I float in liquid gardens
    UTC -7ąDS

  3. #3
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: DistributionList Details (2000)

    Try this starter code. It requires pre-selection of the distribution list.

    Public Function GetCurrentItem() As Object
    On Error Resume Next
    If TypeName(Application.ActiveWindow) = "Explorer" Then
    Set GetCurrentItem = ActiveExplorer.Selection(1)
    Else
    Set GetCurrentItem = ActiveInspector.CurrentItem
    End If
    End Function

    Sub ContactFromDistList()
    Dim NS As NameSpace
    Dim dlList As DistListItem
    Dim itmsContacts As Items
    Dim lngC As Long, lngD As Long
    Dim strAddrEntryToFind As String, strAddressEntriesToSearch As String
    On Error Resume Next
    Set dlList = GetCurrentItem
    On Error GoTo 0
    If Not dlList Is Nothing Then
    Set NS = Application.GetNamespace("MAPI")
    Set itmsContacts = NS.GetDefaultFolder(olFolderContacts).Items
    For lngC = 1 To dlList.MemberCount
    strAddrEntryToFind = dlList.GetMember(lngC).Address
    For lngD = 1 To itmsContacts.Count
    With itmsContacts(lngD)
    If .Class = olContact Then
    strAddressEntriesToSearch = .Email1Address & .Email2Address & .Email3Address
    If CBool(InStr(strAddressEntriesToSearch, strAddrEntryToFind)) Then .Display
    End If
    End With
    Next lngD
    Next lngC
    MsgBox "Done"
    Else
    MsgBox "Selected item is not a Distribution List"
    End If
    Set itmsContacts = Nothing
    Set dlList = Nothing
    Set NS = Nothing
    End Sub
    -John ... I float in liquid gardens
    UTC -7ąDS

  4. #4
    4 Star Lounger
    Join Date
    Aug 2003
    Location
    Stroud, United Kingdom
    Posts
    548
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: DistributionList Details (2000)

    Thanks John!

    After a little study of the code I am getting an idea of how things are referenced in Outlook VBA. This is very helpful <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

    I have managed to get the code to print out ( to the debug window for now..) the name, and telephone numbers of each contact that is in the selected Distribution list. This was my goal, to get the phone numbers out <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

    I have also understood that you can get the .Categories value.

    However , I would like to write to the .Categories value, then I can do a sort on cateogry and export the contacts that have that category. It doesnt work to do the following:

    If CBool(InStr(strAddressEntriesToSearch, strAddrEntryToFind)) Then .Categories = "MARKED"

    any idea of how to Set the value for the category? The help files contain minimal info it seems, I will check MSDN anyways.

    Thanks again <img src=/S/smile.gif border=0 alt=smile width=15 height=15>
    Thanks,

    pmatz

  5. #5
    4 Star Lounger
    Join Date
    Aug 2003
    Location
    Stroud, United Kingdom
    Posts
    548
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: DistributionList Details (2000)

    GOT IT!!

    If CBool(InStr(strAddressEntriesToSearch, strAddrEntryToFind)) Then
    .Categories = "Marked"
    .Save
    End If

    that does it.

    Thanks again
    Thanks,

    pmatz

  6. #6
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: DistributionList Details (2000)

    Glad it worked. It's easy to forget the .Save, I've done it myself.
    -John ... I float in liquid gardens
    UTC -7ąDS

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •