Link to home
Start Free TrialLog in
Avatar of spoowiz
spoowizFlag for United States of America

asked on

Recommend book please. Outlook programming with Visual Basic.

Hi,
Can you recommend your favorite book on how to learn about Outlook programming with Visual Basic - like adding to contact from VB or looking up info in contacts from VB.
Thank you,
Phil
SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore 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
To get contacts, try:

Private Sub cmdGetContact_Click()
    Dim myolApp As Outlook.Application
    Dim mynamespace As Outlook.NameSpace
    Dim myitem As Outlook.ContactItem
    Dim myFolder As Outlook.MAPIFolder
   
    Set myolApp = CreateObject("Outlook.Application")

    Set mynamespace = myolApp.GetNamespace("MAPI")
    Set myFolder = mynamespace.GetDefaultFolder(olFolderContacts)

    Debug.Print "Contacts count = " & myFolder.Items.Count

    For i = 1 To myFolder.Items.Count
        Set myitem = myFolder.Items(i)
        Debug.Print myitem.FullName & ": " & myitem.Email1Address
    Next i

    Set myitem = Nothing
    Set mynamespace = Nothing
    Set myFolder = Nothing
    Set myolApp = Nothing
   
End Sub
Avatar of spoowiz

ASKER

thanks ryancys. however, i'm looking for a book to learn, not only those examples but more.
p.s. the 2nd code will display items in Contacts but not in sub-folders like "hot contacts" under "contacts".
Try like:

...
Set myFolder = mynamespace.GetDefaultFolder(olFolderContacts)
   
    For j = 1 To myFolder.Folders.Count
        Set myFolder = myFolder.Folders(j)
       
        For i = 1 To myFolder.Items.Count
            Set myitem = myFolder.Items(i)
            Debug.Print myFolder.Name & "> " & myitem.FullName & ": " & myitem.Email1Address
        Next i
    Next j
...
ASKER CERTIFIED SOLUTION
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
Avatar of spoowiz

ASKER

I'm closing this question out. Thanks both of you.
I decided on "Developing Applications using Outlook 2000, CDO, Exchange, and Visual Basic..." from amazon.
ryan, you didn't recommend a book but learned from your code so awarding points also.