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()