P
Paul M
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()
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()