Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Interop / February 2004

Tip: Looking for answers? Try searching our database.

outlook  contacts and distribution lists - help???

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Paul M - 09 Feb 2004 17:29 GMT
Hi there,

i'm trying to create code that will retrieve the distribution lists in my
contacts folder, and show me the entries in there, but i am having many
problems with it.

i have some similar code that loops through contacts and adds them to a new
distribution list but it is also giving my problems as the
GetDefaultFolder(olFolderContacts).Items  is not a collection class.

Any help appreciated.

thanks,
Paul    - CODE BELOW.......

Dim myOlApp As New Outlook.Application

Dim myNameSpace As Outlook.NameSpace

Dim myDistList As Outlook.DistListItem

Dim myContact As Outlook.ContactItem

Dim myRecipient As Outlook.Recipient

myNameSpace = myOlApp.GetNamespace("MAPI")

myDistList = myOlApp.CreateItem(Outlook.OlItemType.olDistributionListItem)

myDistList.DLName = InputBox("Enter the name of the new distribution list")

Dim item As Object

For Each item In myNameSpace.GetDefaultFolder(olFolderContacts).Items

If TypeOf item Is ContactItem Then

myContact = item

myRecipient = myNameSpace.CreateRecipient(myContact.FullName)

myRecipient.Resolve()

myDistList.AddMember(myRecipient)

End If

Next

myDistList.Display()
Ken Slovak - [MVP - Outlook] - 09 Feb 2004 21:11 GMT
You can't use Item like that. Declare an Object variable, since items
in the Items collection can be contacts or DL's.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginners Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm

> Hi there,
>
[quoted text clipped - 46 lines]
>
> myDistList.Display()
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.