Adding Contact and Distribution List Names to a List

C

Clarke

Hello all,
I am trying to add the names of contacts and distribution lists in my
contact folder to a Word list box. My problem is that I don't know how to
test to see whether or not something is a distribution list. Something like
this should work, if someone can help me figure out what the names of the
properties are:
NumItems = currItems.Count
For X = 1 To NumItems
If ??currItems.Item(X) is a contact?? Then
lstContacts.AddItem currItems.Item(X).FileAs
Else 'this is a distribution list, not a contact
lstContacts.AddItem currItems.Item(X).DLName
End If
Next

For some reason this code works will work on contacts and on the first
distribution list, but not on the second list:
Dim NumItems As Integer
NumItems = currItems.Count
For X = 1 To NumItems
On Error GoTo DList
lstContacts.AddItem currItems.Item(X).FileAs
GoTo Finished
DList: lstContacts.AddItem currItems.Item(X).DLName
'this is a distribution list, not a contact
Finished:
Next

Thanks for any help.
 
M

Michael Bauer

Hi Clarke,

use this:

dim obj as object

[...]
Set obj=??currItems.Item(X)

If TypeOf obj Is Outlook.ContactItem Then
' Contact
ElseIf TypeOf obj Is Outlook.DistListItem Then
' Distributionlist
Endif
[...]
 

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