PC Review


Reply
Thread Tools Rate Thread

Avoid a Distribution List when looping through Items ?

 
 
=?Utf-8?B?R29yZG9u?=
Guest
Posts: n/a
 
      1st May 2005
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
 
Reply With Quote
 
 
 
 
Sue Mosher [MVP-Outlook]
Guest
Posts: n/a
 
      1st May 2005
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

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
distribution list adds business fax number- why, and how to avoid? Randy Bratton Microsoft Outlook Contacts 9 2nd Jul 2008 09:50 PM
Distribution list adds business fax number- Why and how to avoid? Randy Bratton Microsoft Outlook BCM 0 13th Jun 2008 04:47 PM
Redemption Data Object - How do you get a static list of message items in the Inbox for looping? Janina Microsoft Outlook VBA Programming 1 8th Dec 2005 08:14 PM
How can I avoid members of a distribution list to see the other's. =?Utf-8?B?RmFyaWQgS2FhYmk=?= Microsoft Outlook BCM 2 10th Mar 2005 12:44 AM
Sent items lists last name in distribution list Carol Microsoft Outlook Discussion 0 14th Jan 2004 03:12 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:35 PM.