Contact Listing

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
 
Q

Question Boy

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
 
S

Sue Mosher [MVP-Outlook]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top