Contact Listing

  • Thread starter Thread starter Question Boy
  • Start date Start date
Q

Question Boy

Hello,

I'm trying to return a listing of contacts from a specific folder. I can
get it to work with the default Contact folder, but cannot get it to use
another folder. Below works, but only for the default contact folder. how
would I need to mod it for a specific folder such as "Business"?

**********
Set myOlApp = CreateObject("Outlook.Application")
Set myNamespace = myOlApp.GetNamespace("MAPI")
'Set MyContacts = myNamespace.GetDefaultFolder(olFolderContacts).Items
Set MyItems = MyContacts
MyItems.Sort "LastName", False 'Sort the entries alphabetically based on
their last names
For Each MyItem In MyItems
List0.AddItem Item:=MyItem.FullName ' add to listbox
Next
**********

Thank you,

QB
 
I managed to get the following function when I hard code the foldername, but
it will not take the select value from a combo box

Set myOlApp = CreateObject("Outlook.Application")
Set myNamespace = myOlApp.GetNamespace("MAPI")
Set MyContacts =
myNamespace.GetDefaultFolder(olFolderContacts).Folders("Business")
Set MyItems = MyContacts.Items
For Each MyItem In MyItems
List0.AddItem Item:=MyItem.FullName ' add to listbox
Next

Why won't Set MyContacts =
myNamespace.GetDefaultFolder(olFolderContacts).Folders(me.cboFldrName) work
then if it returning the value Business just like the hard coded version that
works?

Thank you,

QB
 
The logical answer is that me.cboFldrName might not be returning "Business" after all. Best to get that value as a separate variable so you can easily check its value. Be wary of trailing spaces.
 
Back
Top