You left out a critical statement -- how you are declaring the variable named contact. You need to declare it as Object, not ContactItem.
Then, your test needs to be an If ... Else ... End If block not an If .... End If block. The way you have it now, you're still trying to access the FileAs and Email1Address properties even if it's a DL.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx
"Gordon" <(E-Mail Removed)> wrote in message news:630EE4A5-F0BC-45FD-BFC5-(E-Mail Removed)...
> Hi;
>
> Just where do you place you test statement i.e. myObj.Class =
> olDistributionClass,
> when coding to loop through the contacts.item collection ?
>
> Like this:
>
> For Each contact In objAllContacts
> ' test for type of object
> If contact.Class = olDistributionList Then
> Debug.Print "I've got one"
> End If
>
>
> Debug.Print contact.FileAs & " " & contact.Email1Address
>
> Next
>
> My loop keeps crashing when I hit the DL.
>
> This makes since but how do avoid this ? Test for this type of contact.
> But where ?
>
> Is it just me or is the Outlook Object Model hard to learn ?
> -
>
> Thanks for your responses,
>
> Gordon