With VB6 how can I open the Address Book window from Outlook.

Posted on 2007-10-15
Last Modified: 2008-01-09
With VB6 how can I open the Address Book window from Outlook.

Question by:jlcere
    LVL 14

    Expert Comment

    Please see the code to collect the email address from the outlook
    Add outlook reference

    Private Sub Command1_Click()
     ' Set up Outlook objects.
       Dim ol As New Outlook.Application
       Dim olns As Outlook.NameSpace
       Dim cf As Outlook.MAPIFolder
       Dim c As Outlook.ContactItem
       Dim objItems As Outlook.Items
       Dim Prop As Outlook.UserProperty

       Set olns = ol.GetNamespace("MAPI")
       Set cf = olns.GetDefaultFolder(olFolderContacts)
       Set objItems = cf.Items
       iNumContacts = objItems.Count
       If iNumContacts <> 0 Then
          For i = 1 To iNumContacts
             If TypeName(objItems(i)) = "ContactItem" Then
                Set c = objItems(i)
                 List1.AddItem c.FullName & " - " & c.Email1Address
             End If
          Next i
          MsgBox "Finished."
          MsgBox "No contacts to export."
       End If
    End Sub


    Author Comment

    Thanks to help me.

    If my address book have several folders, how can I select a specific one.
    Ex. I have my personal contact, the office contact....

    And do you have a link where I can learn the code you wrote.

    Thanks again.
    LVL 14

    Accepted Solution


    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Share codes 68 104
    Watch V7 9 49
    LINQ return type for nested group query 6 51
    DIR issue 7 39
    Article by: Martin
    Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
    Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now