Solved

Outlook Contact Form

Posted on 2011-02-15
6
280 Views
Last Modified: 2013-11-05
Does anyone know how to load the Outlook Contact Form which has all the contacts information based on the contacts EntryID in vb6.

Any help would be appreciated.
0
Comment
Question by:PhilChapmanJr
  • 3
  • 3
6 Comments
 
LVL 76

Expert Comment

by:David Lee
ID: 34906929
Hi, PhilChapmanJr.

Sorry, I don't understand what you mean.  Can you explain?
0
 
LVL 2

Author Comment

by:PhilChapmanJr
ID: 34907169
I can load the contacts by using the code below.

The objItem.EntryID is the actual contacts Outlook ID number

I'm storing the objItem.EntryID as a key in the ListView

What I need to do is dbl-clieck on the desired ListView item and

Get the correct objItem and then do a
objItem.Display
Which will pull up the Outlook Contact Form.



Private Sub Command1_Click()

Dim strTemp As String
Dim RecCount As Long


Dim lngLoop As Long
On Error GoTo Main_Error
 
Set objApp = New Outlook.Application
Set objNS = objApp.GetNamespace("MAPI")
Set colAdressFolders = New Collection
Set objFolder = objNS.Folders.GetFirst ' get root-folder

For lngLoop = 1 To objFolder.Folders.Count
    If objFolder.Folders.Item(lngLoop).DefaultItemType = olContactItem Then
        RecursiveSearch objFolder.Folders.Item(lngLoop), colAdressFolders
    End If
Next lngLoop

ListView.ListItems.Clear
LockWindowUpdate ListView.hWnd

RecCount = 0
For Each objFolder In colAdressFolders
    For lngLoop = 1 To objFolder.Items.Count
        Set objItem = objFolder.Items(lngLoop)
        Set itmX = ListView.ListItems.Add(, "K" & objItem.EntryID, objItem.EntryID)
       
        itmX.SubItems(1) = objItem.CompanyName
        itmX.SubItems(2) = objItem.FullName
        itmX.SubItems(3) = ""
    Next
Next
On Error GoTo 0
LockWindowUpdate 0
Exit Sub
 
Main_Error:
   
    MsgBox "Error " & Err.Number & " (" & Err.Description & ")" & objItem.FullName
    Resume Next
End Sub


Private Sub RecursiveSearch(objSubFolder As Outlook.MAPIFolder, colAdrFolders As Collection)
 
Dim lngLoop As Long


If objSubFolder.Items.Count > 0 Then
    'add reference to collection
    colAdrFolders.Add objSubFolder
    cmbAddressBooks.AddItem objSubFolder
End If
 
If objSubFolder.Folders.Count > 0 Then
    For lngLoop = 1 To objSubFolder.Folders.Count
        If objFolder.Folders.Item(lngLoop).DefaultItemType = olContactItem Then
            RecursiveSearch objSubFolder.Folders.Item(lngLoop), colAdrFolders
        End If
    Next lngLoop
End If
If cmbAddressBooks.ListCount > 0 Then cmbAddressBooks.ListIndex = 0
Exit Sub
Errorhandler:
MsgBox "An unexpected error occured methode RECURSIVESEARCH", vbCritical + vbOKOnly, "Problem"
Err.Clear

On Error GoTo 0
Exit Sub
   
RecursiveSearch_Error:
    MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure RecursiveSearch of Module modOutlook"
End Sub
 
0
 
LVL 76

Accepted Solution

by:
David Lee earned 500 total points
ID: 34907280
Got it.  That's simple.
Set olkContact = objNS.GetItemFromID(the_entry_id_of_the_Item_from_your_listview)
olkContact.Display

Open in new window

0
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 
LVL 2

Author Comment

by:PhilChapmanJr
ID: 34907474
Works Great!

Thanks
0
 
LVL 2

Author Closing Comment

by:PhilChapmanJr
ID: 34907480
Thanks
0
 
LVL 76

Expert Comment

by:David Lee
ID: 34907586
You're welcome!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying 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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…

830 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