You are currently offline, waiting for your internet to reconnect

OL2002: How to Handle Unexpected Items in a Collection

This article was previously published under Q292062
This article has been archived. It is offered "as is" and will no longer be updated.
If you are using the Outlook object model to loop through items in a folder, you should make sure your solution will work even if the folder contains items that you might not expect to be there.
More information
Examples of items that you might unexpectedly find in a folder include:
  • A Meeting or Task Request item in the Inbox.
  • An item that is a file from an external source, such as a Microsoft Word document or a Microsoft Excel spreadsheet. These files may be directly posted into a folder from another application, or they may have been dragged into a folder.
  • A Conflict message sent by Microsoft Exchange, if more than one person has edited an item at the same time in a public folder.
  • An item that is based on a form designed using the Exchange Forms Designer (EFD). These types of items do not function exactly like Outlook items in all circumstances. For example, you cannot programmatically add an attachment that is a link to an EFD-based item.
  • A Distribution List item in a Contacts folder. These lists arestored in the default Contacts folder and have a message class of IPM.DistList.
The Inbox typically poses a concern since the user generally has less control over what items are placed in that folder. Also, Outlook fully introduces Distribution Lists into the Contacts folder.

NOTE: In Outlook 98 (using Internet Mail Only mode), these distibution lists could exist in the folder but were not visible through the user interface. They were created and stored by the Windows Address Book.

Typically you will not run into problems when your code references one ofthese items. Problems usually occur when you try to reference a property ofa particular item type and that property does not exist.

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs.
If you have limited programming experience, you may want to contact a Microsoft Certified Partner or Microsoft Advisory Services. For more information, visit these Microsoft Web sites:

Microsoft Certified Partners -

Microsoft Advisory Services -

For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:;EN-US;CNTACTMSThe following are approaches you can use to avoid these types of problems.Choose the approach that is best suited to your solution, the type offolder you are working with, and the types of items that could potentiallyaffect your solution.

  • Use the TypeName function to test the type of object being referenced.
    If TypeName(objMyItem) = "ContactItem" Then...					
  • Check the MessageClass property of an item.
    If Left(objMyItem.MessageClass, 11) = "IPM.Contact" Then...					
  • Use error trapping to simply skip over lines of code that may potentially cause a problem.
    For Each oMyMailItem in oMyInboxItems   On Error Resume Next   oMyMailItem.VotingOptions = ""   oMyMailItem.SaveNext					
For additional information about available resources and answersto commonly asked questions about Microsoft Outlook solutions, click the article number below to view the article in the Microsoft Knowledge Base:
287530 OL2002: Questions About Custom Forms and Outlook Solutions
OfficeKBHowTo OutSol OutSol2002
Note This is a "FAST PUBLISH" article created directly from within the Microsoft support organization. The information contained herein is provided as-is in response to emerging issues. As a result of the speed in making it available, the materials may include typographical errors and may be revised at any time without notice. See Terms of Use for other considerations.

Article ID: 292062 - Last Review: 10/24/2013 05:12:00 - Revision: 1.0

Microsoft Outlook 2002 Standard Edition

  • kbnosurvey kbarchive kbhowto KB292062