Solved

Outlook Contact Form

Posted on 2011-02-15
6
278 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
Comment Utility
Hi, PhilChapmanJr.

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

Author Comment

by:PhilChapmanJr
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 2

Author Comment

by:PhilChapmanJr
Comment Utility
Works Great!

Thanks
0
 
LVL 2

Author Closing Comment

by:PhilChapmanJr
Comment Utility
Thanks
0
 
LVL 76

Expert Comment

by:David Lee
Comment Utility
You're welcome!
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…

744 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

13 Experts available now in Live!

Get 1:1 Help Now