Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook Contacts

Status
Not open for further replies.

gpalmer711

IS-IT--Management
Joined
May 11, 2001
Messages
2,445
Location
GB
Does anyone know how to do the following? I am using the MS Outlook ViewCtl to display my Outlook Contacts in Visual Basic. This I can do without any problems. However what I would like to do is select a contact and then copy that contacts address details to various text boxes. Greg Palmer

----------------------------------------
Any feed back is appreciated.
 
I think this addresses your question if you put the code within a sub

Dim Item As Outlook.ContactItem
Dim olContactFolder As Outlook.MAPIFolder
Dim i As Integer

Set OlApp = CreateObject("Outlook.Application")
Set ns = OlApp.GetNamespace("MAPI")
Set OlContacts = ns.GetDefaultFolder(olFolderContacts)

For i = 1 To OlContacts.Folders.Count
For Each Item In OlContacts.Folders(i).Items
Text(i).text = Item.Email1Address 'Or what ever info you want

Next Item
Next i
 
I cannot get the code to work. Perhaps I didn't explain myself properly. What I have is a Outlook ViewCtl on my form. I also have a say 2 text boxes one for the first and one for the last name. What I would like to do is click on one of the contacts in my ViewCtl and then click on a command button. The Click event should copy the first and last name from the selected contact to the relevant textboxes.

Many Thanks Greg Palmer

----------------------------------------
Any feed back is appreciated.
 
I have managed to work out the correct code for the above.

Private Sub Command1_Click()
Dim Item As Outlook.ContactItem
For Each Item In OLookViewCtl.Selection
Text1.Text = Item.FirstName 'Or what ever info you want
Next Item
End Sub Greg Palmer

----------------------------------------
Any feed back is appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top