How can I get a list of all email stored in the outlook address book? I'm going to use this in an axtivex 'tell a friend' control.
/Niels Bosma
Printable View
How can I get a list of all email stored in the outlook address book? I'm going to use this in an axtivex 'tell a friend' control.
/Niels Bosma
Code:Option Explicit
Private Sub Form_Load()
'set a reference to outlook in references
Dim moMail As Object
Dim loNameSpace As Object
Dim loNameAddresses As Object
Dim loAddresses As Object
Dim loAddressList As Object
Set moMail = New Outlook.Application
Dim moAddresses As Outlook.AddressLists
Set loNameSpace = moMail.GetNamespace("MAPI")
Set loAddresses = loNameSpace.AddressLists("Contacts")
Set loAddressList = loAddresses.AddressEntries
List1.Clear
Dim intcre As Integer
For intcre = 1 To loAddressList.Count
List1.AddItem loAddressList.Item(intcre).Name
List1.AddItem loAddressList.Item(intcre).Address
List1.AddItem "________________________________"
List1.AddItem ""
Next intcre
End Sub
Private Sub List1_Click()
Dim SendMe As String
SendMe = List1.Text
ShellExecute hwnd, "open", "mailto:" & SendMe, vbNullString, vbNullString, SW_SHOW
End Sub
thanks for the code!, but...
I can't find Outlook in my reference list. I have outlook express on my computer and the program has to work with both versions !?! Do I have to intall the full office version on outlook?
/Niels
I don't know for sure but I would think this will only work for Outlook/full version.
I get runtime error on this line:
Set loAddresses = loNameSpace.AddressLists("Contacts")
('Object could not be found')
/Niels
Are you trying this on a network. If you are, it more than likely won't work because any good network will have their address list on a drive that is not accessable to anyone without superviory or administrative authority.