More Outlook Resource Sites

Microsoft Developer Network (MSDN)

FAQs and other general resources

To generate an ID number for an Outlook item

Once you move beyond simple Outlook forms, you will probably encounter situations where you want to link different types of Outlook items. The only method built into Outlook is the Links collection, which allows items to be connected to one or more ContactItem items. Most scenarios that need an ID require something more than this-- either a unique ID number or an ID that is not only unique but also sequential. This page reviews various techniques that can be used to generate such an ID.

Nonsequential IDs

The sample code for my Microsoft Outlook Programming book (available for download) includes two functions that generate nonsequential IDs:

  • Listing 20.5 - NewConversationIndex() - uses a ConversationIndex value generated by CDO
  • Listing 20.6 - DateID - uses the date and time to generate an eleven-character string; not suitable for high-volume situations, but OK for occasional use

The date-based ID is more suitable where a human-readable ID is required.

If you're using a .NET language, you can call System.Guid.NewGuid() to create a new globally unique ID. See Generating and working with GUIDs in .NET.

Sequential IDs

Database method

You can use a multi-user database with an autonumbering table to generate sequential IDs. See Listing 23.7 in my book (and also 23.3, which it uses) for an ADO sample. There is also an ongoing discussion of this code.

For DAO samples, see:

Hidden item method

Another approach is to use CDO to create an item in the HiddenMessages collection of a folder and use a property in that item to store the latest number. Your code would increment that number and save the item after each use, as in this sample from Outlook MVP Ken Slovak.

Republish form method

Outlook MVP Richard SIlva suggests a method that involves republishing an Outlook form after incrementing the numbering property. Since only the folder owner can publish the form, this method probably is not practical for use in a public folder. 


Using the value of the EntryID associated with an Outlook item is an appealing choice for an ID number, because it can be used with the Namespace.GetItemFromID method to open an item directly. The problem is that, in most cases, the EntryID changes when the item is moved. Therefore, it's suitable only if you can depend on the item note moving, such as a case where you want to synchronize a database table with the items in a particular public folder.

Also beginning with Service Pack 2 for Office 2003, Outlook appointment and meeting requests items exhibit a different behavior that makes the EntryID unsuitable as an ID number. The MSKB article Developer information about the calendar changes in Outlook 2003 Service Pack 2 and later versions explains that when a user receives an update to a meeting, Outlook will delete the original appointment and create a new one. The reason for this change is to resolve problems related to meetings disappearing from the Calendar, but because a new item is created, any application that depends on using an appointment's EntryID to retrieve it later will need to use a different technique.