Results 1 to 11 of 11

Thread: Global address book names in a list view

Hybrid View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2005
    Posts
    151

    Re: Global address book names in a list view

    Hello Sir !

    I have made certain changes in ur code and able to run it.

    Code:
     Dim oAEntries As AddressEntries
     Dim oAEntry As AddressEntry
     Dim oFields As Field
    Now i am getting the details in a listview.

    I am trying to take only Lastname,FirstName(In single column) in a listview or(it can be listbox also) and emailaddress as hidden field because i want email address of the seleted person. I am trying to write code for this with the help of your code but not getting the desired output...

    Can u guide me on this issue....

    Thanks...

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Sep 2005
    Posts
    151

    Re: Global address book names in a list view

    Hello !

    Its getting really difficult for me to get this....
    Code:
    Dim objoutlk As New Outlook.Application
    Dim fol As Outlook.mapiFolder
    Dim mapises As MAPI.Session
    Dim contact As Outlook.ContactItem
    Dim ns As Outlook.NameSpace
    Dim var1 As String
    Private Const cdoPR_GIVEN_NAME As Long = &H3A06001E
    Private Const cdoPR_SURNAME As Long = &H3A11001E
    Private Const cdoPR_EMAIL As Long = &H39FE001E
    
    Private Sub Form_Load()
    
    Set ns = objoutlk.GetNamespace("MApi")
    Set fol = ns.GetDefaultFolder(olFolderContacts)
    Me.Show
    For Each contact In fol.Items
        List1.AddItem contact.FirstName & " , " & contact.LastName
        
    Next
    Set mapises = CreateObject("MAPI.session")
    mapises.Logon "", "", False, False
    gal
    Set ns = Nothing
    Set objoutlk = Nothing
    Set fol = Nothing
    
    End Sub
    
    Public Sub gal()
    
        Dim oAEntries As AddressEntries
        Dim oAEntry As AddressEntry
        Dim oFields As Field
        Dim i As Integer
        Dim ii As Integer
        Dim iii As Integer
        Dim vDetails As Variant
        
    On Error GoTo errorfun
        Set oAEntries = mapises.AddressLists.Item("Global Address List").AddressEntries
        For i = 1 To oAEntries.Count
            Set oAEntry = oAEntries.Item(i)
            var1 = ""
            For ii = 1 To oAEntry.Fields.Count
            
                Set oFields = oAEntry.Fields(ii)
                vDetails = oFields.Value
                If oFields.ID = cdoPR_SURNAME Then
                    var1 = var1 & vDetails & " , "
                    
                ElseIf oFields.ID = cdoPR_GIVEN_NAME Then
                    var1 = var1 & vDetails
                    MsgBox var1
                    List1.AddItem var1
                End If
            Next
            
        Next
    errorfun:
    gal
    End Sub
    I am able to get firstname and lastname of all the contacts in a listbox.
    I want email ids of all of them.
    I am taking lastname,firstname in one column... Is there any way i can get emailid of all these in second column(which will be hidden).

Posting Permissions

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



Click Here to Expand Forum to Full Width