Solved

Recommend book please. Outlook programming with Visual Basic.

Posted on 2004-08-05
6
173 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 49

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 49

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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 49

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now