Solved

Outlook Contact Form

Posted on 2011-02-15
6
281 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
[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
  • 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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…

751 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