How to get Outlook address book names via VBA?
Outlook has the option to create multiple address books. Of course, it's for a good reason, to organize address books.
Well, why need to organize? I guess the reason will depend on every individual whether it's a thing to practice or a thing to be ignored.
Outlook address book can be set to manage contacts.
For example, you can have an address book just for Personal use which includes friends and family.
You can set the address book for vendors and another address book for customers only and of course contacts within the organization.
Organizing is a skill if not an attitude to make work easier and manageable.
VBA code below will get all the address book names on Outlook, and once the address book is known you can expand the code to get contacts for each specific address book by supplying the address book name.
Dim mContact As AddressList
Dim mAddressBook As AddressLists
Dim fs, f
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.CreateTextFile("d:\Outlook_AdressBook_Name.txt", True)
Set mAddressBook = Application.GetNamespace("MAPI").AddressLists
f.WriteLine "Outlook Address Book Names:"
On Error Resume Next
For Each mContact In mAddressBook
' MsgBox mContact.GetContactsFolder.AddressBookName
‘Close to release the memory used by the variable
Outlook Address Book Names:
Contacts - Public Folders
Windows Live Messenger
Customers - East
Vendors - IT Contacts
Cheers..hope it helps.. till next time.
Linux Android App cheat sheet:
Free Android Apps:
Click on links below to find out more:
Catholic Rosary Guide for Android:
Divine Mercy Chaplet Guide (A Powerful prayer):
Educational Android App for Kids: