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.
======================================
Sub getfoldercontact_addressbook_names()
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
f.WriteLine mContact.GetContactsFolder.AddressBookName
Next mContact
‘Close to release the memory used by the variable
f.Close
fs.Close
End Sub
======================================
Sample Output:
Outlook Address Book Names:
Contacts - Public Folders
LinkedIn
Suggested Contacts
Windows Live Messenger
Customers - East
Vendors - IT Contacts
Personal Contacts
Cheers..hope it helps.. till next time.
Linux Android App cheat sheet:
https://play.google.com/store/apps/details?id=com.LinuxMobileKit
Free Android Apps:
Click on links below to find out more:
https://play.google.com/store/apps/details?id=soulrefresh.beautiful.prayer
Catholic Rosary Guide for Android:
https://play.google.com/store/apps/details?id=com.myrosaryapp
http://quickbytesstuff.blogspot.sg/2014/09/how-to-recite-rosary.html
Divine Mercy Chaplet Guide (A Powerful prayer):
https://play.google.com/store/apps/details?id=com.dmercyapp
Educational Android App for Kids:
https://play.google.com/store/apps/details?id=com.xmultiplication
https://play.google.com/store/apps/details?id=com.letsmultiply
Comments
Post a Comment