How make list of the other folder contact ? 
Author Message
 How make list of the other folder contact ?

In my default contact folder, i have another contact's folder. How I
can have the list of this folders ?

Tue, 19 Oct 2004 12:02:56 GMT  
 How make list of the other folder contact ?
Hi Bruno!

The sample shows how to iterate through all folders and how to identify a
Contact filder. If a Contact folder is found it also prints the names of the
contacts in that specific folder.

It can easily be modified to only look in a specific Contact folder.

The vb project needs a command button and a multiline textbox. It also need
a reference to a Outlook OLB.

I hope this helps you.

Option Explicit
Private OutlookApp As Outlook.Application
Private ns As NameSpace

Private Sub Form_Load()
    'Initialize Outlook objects
    Set OutlookApp = CreateObject("Outlook.Application")
    Set ns = OutlookApp.GetNamespace("MAPI")
End Sub

Private Sub Command1_Click()
    'Clear textbox
    Text1.Text = ""
    'Call recursive function
    GetAllContactFoldersRecurse ns.Folders
End Sub

Private Function GetAllContactFoldersRecurse(AFolder As Folders) As Boolean
Dim MyContacts As MAPIFolder
Dim I%

    'Loop through all folders
    For I% = 1 To AFolder.Count
        'Check folder type
        If AFolder.Item(I%).DefaultMessageClass = "IPM.Contact" Then
            'A Contact folder
            Text1.Text = Text1.Text + AFolder.Item(I%).Name + " <- Contact
folder" + vbCrLf
            GetAllContactsRecurse AFolder.Item(I%)
            'Not a Contact folder
            'Text1.Text = Text1.Text + AFolder.Item(I%).Name + vbCrLf
        End If
        'Any sub folders?
        If AFolder.Item(I%).Folders.Count > 0 Then
            GetAllContactFoldersRecurse AFolder.Item(I%).Folders
        End If
    Next I%
End Function

Private Function GetAllContactsRecurse(AFolder As MAPIFolder) As Boolean
Dim MyItem As Object 'ContactItem
Dim I%
Dim NofItems%

    For Each MyItem In AFolder.Items
        If Not MyItem Is Nothing Then
            If MyItem.MessageClass = "IPM.Contact" Then
                With MyItem
                    Text1.Text = Text1.Text + vbTab + .FirstName + " " +
.LastName + vbCrLf
                End With
            End If
        End If
    Next MyItem
End Function


> In my default contact folder, i have another contact's folder. How I
> can have the list of this folders ?
> Thanks
> Bruno

Mon, 01 Nov 2004 22:37:37 GMT  
 [ 2 post ] 

 Relevant Pages 

1. Members property of contact folder distribution lists - returns gobbledygook in lovely looking array

2. Getting Contact list from another FOLDER

3. Distribution lists in the Contacts Folder

4. Using VBA to Create a Contact Folder Distribution List from MS Access

5. Set Contact Folder to be E-Mail Address List in Code

6. Get list of all Contact folder names

7. Deleting Contacts and Dist Lists in same folder

8. Public Folder Contact List

9. Diostribution list from contacts ion public folders

10. Getting List Of Contact Folders

11. Delete Contacts from "Contact " Folder Automatically

12. From a Contact's details to the Contact folder


Powered by phpBB® Forum Software