Solved

Recommend book please. Outlook programming with Visual Basic.

Posted on 2004-08-05
6
178 Views
Last Modified: 2013-11-25
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
0
Comment
Question by:spoowiz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 52

Assisted Solution

by:Ryan Chong
Ryan Chong earned 25 total points
ID: 11732935
Here is an example to add contact on Outlook Contact:

Private Sub Command9_Click()
    Dim iOutlook As Outlook.Application
    Dim contact As Outlook.ContactItem
    Set iOutlook = New Outlook.Application
    'Set iOutlook = CreateObject("outlook.Application")
   
    Set contact = iOutlook.Application.CreateItem(olContactItem)
    With contact
   
        .FirstName = "TEST"
        .LastName = "XX"
        .JobTitle = outlook_query(qualification)
        .CompanyName = "Free Lancer"
        .Categories = " Present & Past Personnel"
       
        .Body = "This Outlook Contact was generated automatically by  PERSONNEL Database Program / Note that in case Business mobile and Home Mobile are different, then Business Mobile located under Car Mobile, and the residence one under Pager."
       
        .HomeAddressStreet = outlook_query(contact_home_address)
        .HomeAddressCountry = outlook_query(contact_home_Country)
        .HomeAddressCity = outlook_query(contact_home_city)
        .HomeAddressPostalCode = outlook_query(contact_home_zip)
        .HomeTelephoneNumber = outlook_query(contact_home_telephone)
        .Home2TelephoneNumber = outlook_query(contact_home_telephone_2)
        .MobileTelephoneNumber = outlook_query(contact_home_mobile)
        .HomeFaxNumber = outlook_query(contact_home_fax)
        '.Email1DisplayName = "Home E-mail"
        .Email1Address = "me@domain1.com"
        'MsgBox .Email1DisplayName
        .OtherAddressStreet = outlook_query(contact_res_address)
        .OtherAddressCountry = outlook_query(contact_res_Country)
        .OtherAddressCity = outlook_query(contact_res_city)
        .OtherAddressPostalCode = outlook_query(contact_res_zip)
        .OtherTelephoneNumber = outlook_query(contact_res_telephone)
        .OtherTelephoneNumber = outlook_query(contact_res_telephone_2)
        .PagerNumber = outlook_query(contact_res_mobile & "(Res. Mobile)")
        .OtherFaxNumber = outlook_query(contact_res_fax & "Res. Fax")
        '.Email2DisplayName = "Residence E-mail"
        .Email2Address = "me@domain2.com"
        'MsgBox .Email2DisplayName
       
        .BusinessAddressStreet = outlook_query(contact_job_address)
        .BusinessAddressCountry = outlook_query(contact_job_Country)
        .BusinessAddressCity = outlook_query(contact_job_city)
        .BusinessAddressPostalCode = outlook_query(contact_job_zip)
        .BusinessTelephoneNumber = outlook_query(contact_job_telephone)
        .Business2TelephoneNumber = outlook_query(contact_job_telephone_2)
        .CarTelephoneNumber = outlook_query(contact_job_mobile & "(Work Mobile)")
        .OtherFaxNumber = outlook_query(contact_job_fax & "Res. Fax")
        .Email3Address = outlook_query(contact_job_e - mail)
       
        .Save
        MsgBox "Done!"
    End With
End Sub

Try customize it
0
 
LVL 52

Expert Comment

by:Ryan Chong
ID: 11732951
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
0
 

Author Comment

by:spoowiz
ID: 11732970
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".
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
LVL 52

Expert Comment

by:Ryan Chong
ID: 11734179
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
...
0
 
LVL 76

Accepted Solution

by:
David Lee earned 25 total points
ID: 11738321
The book I use is "Building Applications with Microsoft Outlook 2000 Technical Reference", ISBN 0-7356-0581-5.  It's from Microsoft Press.  
0
 

Author Comment

by:spoowiz
ID: 11991939
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.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

729 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