Solved

Recommend book please. Outlook programming with Visual Basic.

Posted on 2004-08-05
6
176 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 51

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 51

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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
LVL 51

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

749 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