Link to home
Start Free TrialLog in
Avatar of jlcere
jlcere

asked on

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

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

Thanks
Avatar of raja_ind82
raja_ind82
Flag of India image

Hi,
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."
   Else
      MsgBox "No contacts to export."
   End If
End Sub

Regards,
M.Raja
Avatar of jlcere
jlcere

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of raja_ind82
raja_ind82
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial