Consulting

Results 1 to 6 of 6

Thread: How to filter contact and distribution list

  1. #1

    How to filter contact and distribution list

    Dear All,

    I recently find the contact management of MS outlook is very useful.
    I have used it as a soft copy of all my contact book.

    And sometime print it out. But what I found limited, so I write here to look for help :
    1. The first point is the distribution list vs. contact. Is there anywhy to filter the distribution list so contact book just show real contact. From the "customize current view", I found there are a lot of field,but I did not find the field that help to distinguish between distribution list and contact.
    2. Company management: is there anyway to manage the company information?
    For example: I have 30 contacts at the same company. Everytime the company change the address, I have to change one by one all of these 30 contacts.

    Thanks all in advance.
    Regards,

  2. #2
    VBAX Master
    Joined
    Jul 2006
    Location
    Belgium
    Posts
    1,286
    Location
    Do you mean the addresses in the distribution list ?

    Charlize

  3. #3
    Let I say more about my troubles:
    1. In the address (or contact) in MS outlook, sometimes, I just need to see and print the contact, but not the distribution list. In MS Outlook, I find there is the filter to filter what we want to see, but I dont know how to filter contact out of distribution list.

    2. Also in the contact, there are some contacts of the same company, and is there any way to let MS outlook manage it?
    For example, when I change the address of the company, all the contact of that company must be changed accordingly.

    Thanks for your answer
    Last edited by yurble_vn; 06-19-2008 at 10:52 AM.

  4. #4
    VBAX Master
    Joined
    Jul 2006
    Location
    Belgium
    Posts
    1,286
    Location
    Something like this ?[VBA]Sub Alter_Mails_For_Company()
    'Holds the searchstring
    Dim mycompany As String
    'Create a message to display
    Dim myresult As String
    Dim mycontact As Outlook.ContactItem
    Dim myfolder As Outlook.MAPIFolder
    'Type the exact name of the company
    'that is filled in for the field company
    'of every contact
    mycompany = InputBox("Give Companyname to list contacts from.", _
    "Get contacts of certain Company.")
    'Get default folder that you use for contacts
    Set myfolder = Application.Session.GetDefaultFolder(olFolderContacts)
    'If you use distribution lists, you'll get an error
    'so we skip and continue with the next contact
    On Error Resume Next
    For Each mycontact In myfolder.Items
    'The company of the addressentry = searchstring
    If mycontact.CompanyName = mycompany Then
    myresult = myresult & mycontact.FullName & vbCrLf
    End If
    Next mycontact
    'Restore the errortrapping
    On Error GoTo 0
    If myresult <> "" Then
    MsgBox "Contacts for " & mycompany & " :" & vbCrLf & myresult, vbInformation
    Else
    MsgBox "No contacts found for " & mycompany, vbInformation
    End If
    End Sub[/VBA]Charlize

  5. #5
    VBAX Master
    Joined
    Jul 2006
    Location
    Belgium
    Posts
    1,286
    Location
    This variation will check if an item in your contactsfolder is a contact or a distributionlist.[VBA]Sub Distribution_or_not()
    Dim myfolder As Outlook.MAPIFolder
    Dim vloop As Long
    Set myfolder = Application.Session.GetDefaultFolder(olFolderContacts)
    For vloop = 1 To myfolder.Items.Count
    'Check if the class of an item is contact, distribution
    'or something else
    If myfolder.Items(vloop).Class = olContact Then
    MsgBox myfolder.Items(vloop).FullName & " is a contact."
    ElseIf myfolder.Items(vloop).Class = olDistributionList Then
    MsgBox myfolder.Items(vloop) & " is a distributionlist."
    Else
    MsgBox myfolder.Items(vloop) & " isn't a" & vbCrLf & _
    "contact or distributionlist"
    End If
    Next vloop
    End Sub[/VBA]Charlize

  6. #6
    VBAX Master
    Joined
    Jul 2006
    Location
    Belgium
    Posts
    1,286
    Location
    Variation on checking persons that work for a certain company. The previous example didn't worked all the time (don't know the reason - perhaps the for each loop ?). This version seems to do what I want it to do.[VBA]Sub List_Possible_Companys()
    Dim myfolder As Outlook.MAPIFolder
    Dim mycontact As Outlook.ContactItem
    Dim mycompany As String
    Dim myresult As String
    Dim vloop As Long
    mycompany = InputBox("Give Companyname to list contacts from.", _
    "Get contacts of certain Company.")
    Set myfolder = Application.Session.GetDefaultFolder(olFolderContacts)
    For vloop = 1 To myfolder.Items.Count
    If myfolder.Items(vloop).Class = olContact Then
    Set mycontact = myfolder.Items(vloop)
    If mycontact.CompanyName <> vbNullString Then
    If mycontact.CompanyName = mycompany Then
    myresult = myresult & "- " & mycontact.FullName & vbCrLf
    End If
    End If
    End If
    Next vloop
    If myresult <> vbNullString Then
    MsgBox "People that work for " & mycompany & " :" & _
    vbCrLf & myresult, vbInformation
    ElseIf mycompany <> vbNullString Then
    MsgBox "No one found for : " & mycompany, vbInformation
    Else
    MsgBox "No search criteria was specified ...", vbInformation
    End If
    End Sub[/VBA]Charlize

Posting Permissions

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