PDA

View Full Version : accessing outlook global address book



talytech
07-14-2009, 08:00 AM
Hi there. I have two questions.

1. Is there a way to check for an email address in the current user's outlook? For example. I have a button (btn1) .. when you click on it it promts the user to enter an email address in the input box. after entering the email, you click OK and at that point, I need for it to check and make sure the email address is found in the global address book in outlook. if it is found the run code to automatically send the Excel spreadsheet to the specified address. Is that possible?

If that isn't possible then next option .....

2. Is there a way to access the current user's global address book in outlook from Excel? For example. When the user clicks btn1 .. the address book is activated and the user can select the email address and then run code to automatically send the Excel spreadsheet to the specified address.

Any help is appreciated.

Thanks

Simon Lloyd
07-14-2009, 01:59 PM
Here's an example that uses a controls toolbox listbox on a worksheet and populates it with all the contacts from the global address book, you could probaly then use Sheets("MySheet").Listbox1.Value as your email address.

Its not my code nor my forte but it gets you nearer your goal!

you will probably need to add the reference from the TOOLS>REFERENCES for Microsoft Outlook 11.0 Object Library
Public Sub Getaddresses()

Dim Addbox As Object
Dim outApp As Object, outNS As Outlook.Namespace
Dim myAddressList As Outlook.AddressList
Dim outItem As Object
Dim people As Integer

Set Addbox = Sheets("MySheet").ListBox1
Set outApp = CreateObject("Outlook.Application")
Set outNS = outApp.GetNamespace("MAPI")
Set myAddressList = outNS.Session.AddressLists("Global Address List")

For Each outItem In myAddressList.AddressEntries
Addbox.AddItem outItem
Next
Set outApp = Nothing

End Sub

talytech
07-16-2009, 11:34 AM
thank you .. I will try this.