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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB with OutLook question 1

Status
Not open for further replies.

bakerm

Programmer
Apr 25, 2000
53
US
Hello All!!!!

Is there a way to get a list of names, like the mailing list, from OuLook via VB code.

Thanks in adavance for any help!
 
Look at using the Outlook object.

Add a reference to Outlook in your project. Then try something like:

Private Sub Command1_Click()
Dim myOlApp As Outlook.Application
Dim myNamespace As Outlook.NameSpace
Dim myAddresslist As Outlook.AddressList
Dim myAddressentry As Outlook.AddressEntry
Dim myCounter
myCounter = 1

Set myOlApp = CreateObject("Outlook.Application")
Set myNamespace = myOlApp.GetNamespace("MAPI")
Set myAddresslist = myNamespace.AddressLists(1)

For Each myAddressentry In myAddresslist.AddressEntries
Set myAddressentry = myAddresslist.AddressEntries(myCounter)
List1.AddItem myAddressentry
Set myAddressentry = Nothing
myCounter = myCounter + 1
Next
myOlApp.Quit
Set myOlApp = Nothing

End Sub

This is an outline only and as such has no error checking - it only assumes a command button and a listbox on a form!
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Thanks John!!! Works Perfect!!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top