Distribution List or Contact- Identifying each in a Loop 
Author Message
 Distribution List or Contact- Identifying each in a Loop

How does one determine whether a Contacts item is a Distribution List or a
Contact?
In a loop, I want to check a property of a contact item (e.g.,
.BusinessTelephoneNumber); however this produces an error  when reaching a
Distribution List, despite trying to trap the error.  A simple If-Then would
get me through this if I knew how to identify what type of contact it is.

Any help? It is appreciated.

Bernie



Wed, 20 Jul 2005 23:03:51 GMT  
 Distribution List or Contact- Identifying each in a Loop
Use the Class property:

    Dim objItem as Object

    ' put in some code to get Items collection

    For Each objItem in objFolder.Items
        If objItem.Class = olContact Then
            ' do some contact-related stuff
        End If
    Next

--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
     Microsoft Outlook Programming: Jumpstart
     for Administrators, Power Users, and Developers
     http://www.slipstick.com/books/jumpstart.htm

Quote:

> How does one determine whether a Contacts item is a Distribution List or a
> Contact?
> In a loop, I want to check a property of a contact item (e.g.,
> .BusinessTelephoneNumber); however this produces an error  when reaching a
> Distribution List, despite trying to trap the error.  A simple If-Then would
> get me through this if I knew how to identify what type of contact it is.

> Any help? It is appreciated.

> Bernie



Thu, 21 Jul 2005 02:11:52 GMT  
 Distribution List or Contact- Identifying each in a Loop
Worked beautifully. Thank you!



Use the Class property:

    Dim objItem as Object

    ' put in some code to get Items collection

    For Each objItem in objFolder.Items
        If objItem.Class = olContact Then
            ' do some contact-related stuff
        End If
    Next

--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
     Microsoft Outlook Programming: Jumpstart
     for Administrators, Power Users, and Developers
     http://www.slipstick.com/books/jumpstart.htm


Quote:
> How does one determine whether a Contacts item is a Distribution List or a
> Contact?
> In a loop, I want to check a property of a contact item (e.g.,
> .BusinessTelephoneNumber); however this produces an error  when reaching a
> Distribution List, despite trying to trap the error.  A simple If-Then
would
> get me through this if I knew how to identify what type of contact it is.

> Any help? It is appreciated.

> Bernie



Thu, 21 Jul 2005 02:30:54 GMT  
 Distribution List or Contact- Identifying each in a Loop
Great. You should use something similar in any folder where there's a reasonable expectation of having multiple item types, e.g. Inbox, Deleted Items, etc.
Quote:

> Worked beautifully. Thank you!



> Use the Class property:

>     Dim objItem as Object

>     ' put in some code to get Items collection

>     For Each objItem in objFolder.Items
>         If objItem.Class = olContact Then
>             ' do some contact-related stuff
>         End If
>     Next

> --
> Sue Mosher, Outlook MVP
> Outlook and Exchange solutions at http://www.slipstick.com
> Author of
>      Microsoft Outlook Programming: Jumpstart
>      for Administrators, Power Users, and Developers
>      http://www.slipstick.com/books/jumpstart.htm



> > How does one determine whether a Contacts item is a Distribution List or a
> > Contact?
> > In a loop, I want to check a property of a contact item (e.g.,
> > .BusinessTelephoneNumber); however this produces an error  when reaching a
> > Distribution List, despite trying to trap the error.  A simple If-Then
> would
> > get me through this if I knew how to identify what type of contact it is.

> > Any help? It is appreciated.

> > Bernie



Thu, 21 Jul 2005 03:29:25 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Members property of contact folder distribution lists - returns gobbledygook in lovely looking array

2. HELP please for contact from Distribution list

3. Help: Extracting Contact info from distribution list inspector

4. Using VBA to Create a Contact Folder Distribution List from MS Access

5. adding a selected contact to a distribution list

6. Adding a contact to a Distribution List

7. Add a contact to a Distribution List

8. HELP please for contact from Distribution list

9. Looping through contact list

10. getting distribution list from Contacts

11. Outlook Contacts - Distribution Lists

12. Distribution Lists - How to displaying individual contacts in To field

 

 
Powered by phpBB® Forum Software