Solved

Recommend book please. Outlook programming with Visual Basic.

Posted on 2004-08-05
6
174 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
  • 3
  • 2
6 Comments
 
LVL 50

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 50

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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 50

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
using Access 8 68
Need an intro to -- .Net SQL Authorization Manager 7 88
Trouble with References... 5 54
Question to Pivot table 1 53
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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 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…

777 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