Share via

ConversationIndex Property (Message Object)

ConversationIndex Property (Message Object)

The ConversationIndex property specifies the index to the conversation thread of the message. Read/write.



Data Type



The ConversationIndex property is a string that represents a hexadecimal number. Valid characters within the string include the numbers 0 through 9 and the letters A through F (uppercase or lowercase).

A conversation is a group of related messages that have the same ConversationTopic property value. In a discussion application, for example, users can save original messages and responses in their personal folders. Messages can be tagged with the ConversationIndex property so that users can order the messages within the conversation.

The Session object provides the CreateConversationIndex method to create or update a conversation index.

This convention uses concatenated time stamp values, with each new message in the conversation adding a new time stamp to the end of the ConversationIndex string. You can see time relationships among the messages when you sort them by ConversationIndex values.

For more information on conversations, see Working With Conversations.

The ConversationIndex property is not exposed on AppointmentItem objects created by Microsoft® Schedule+, and it is not automatically set when you create an appointment within a CDO application. In these cases, the application must assign a value to ConversationIndex or an attempt to read it returns CdoE_NOT_FOUND.

The ConversationIndex property corresponds to the MAPI property PR_CONVERSATION_INDEX. It can be rendered into HTML hypertext using the CDO Rendering ObjectRenderer object. To specify this, set the object renderer's DataSource property to this Message object and the property parameter of the RenderProperty method to CdoPR_CONVERSATION_INDEX.


This code fragment demonstrates the old procedure used prior to version 1.1 of CDO. It takes advantage of the OLE CoCreateGUID function, which returns a value that consists of a time stamp and a machine identifier. The code fragment saves the time stamp part of the GUID.

For an example of the new procedure available with CDO version 1.1, see the CreateConversationIndex method.

' declarations section
Type GUID ' global unique identifier; contains a time stamp
    Guid1 As Long
    Guid2 As Long
    Guid3 As Long
    Guid4 As Long
End Type
' function appears in OLE32.DLL on Windows NT and Windows 95
Declare Function CoCreateGuid Lib "COMPOBJ.DLL" (pGuid As GUID) As Long
Global Const S_OK = 0 ' return value from CoCreateGuid

Function Util_GetEightByteTimeStamp() As String
Dim lResult As Long
Dim lGuid As GUID
    ' Exchange conversation is a unique 8-byte value
    ' Exchange client viewer sorts by concatenated properties
    On Error GoTo error_actmsg

    lResult = CoCreateGuid(lGuid)
    If lResult = S_OK Then
        Util_GetEightByteTimeStamp = _
            Hex$(lGuid.Guid1) & Hex$(lGuid.Guid2)
        Util_GetEightByteTimeStamp = "00000000" ' zero time stamp
    End If
    Exit Function

    MsgBox "Error " & Str(Err) & ": " & Error$(Err)
    Util_GetEightByteTimeStamp = "00000000"
    Exit Function
End Function

Function Util_NewConversation()
Dim i As Integer
Dim objNewMsg As Message  ' new message object
Dim strNewIndex As String ' value for ConversationIndex
' ... error handling ...
    Set objNewMsg = objSession.Outbox.Messages.Add
' ... error handling ...
    With objNewMsg
        .Subject = "used car wanted"
        .ConversationTopic = .Subject
        .ConversationIndex = Util_GetEightByteTimeStamp() ' utility
        .Text = "Wanted: late-model used car with low mileage."
        Set objOneRecip = .Recipients.Add(Name:="Car Ads", Type:=CdoTo)
        ' or you could pick the public folder from the address book
        If objOneRecip Is Nothing Then
            MsgBox "Unable to create the public folder recipient"
            Exit Function
        End If
        .Update ' save everything in the MAPI system
        .Send showDialog:=False
    End With
End Function

A subsequent reply to this message should copy the ConversationTopic property and append its own time stamp to the original messages time stamp, as shown in the following code fragment:

Function Util_ReplyToConversation()
Dim objPublicFolder As Folder
Dim i As Integer
Dim objOriginalMsg As Message ' original message in public folder
Dim objNewMsg As Message      ' new message object for reply
Dim strPublicFolderID As String ' ID for public folder

    Set objNewMsg = objSession.Outbox.Messages.Add
' error checking ... obtain objOriginalMsg and check that it is valid
    With objNewMsg
        .Text = "How about a slightly used bicycle?" ' new text
        .Subject = objOriginalMsg.Subject ' copy original properties
        .ConversationTopic = objOriginalMsg.ConversationTopic
        ' append time stamp; compatible with Microsoft Exchange client
        .ConversationIndex = objOriginalMsg.ConversationIndex & _
                             Util_GetEightByteTimeStamp() ' new stamp
        ' message was sent to a public folder so can copy recipient
        Set objOneRecip = .Recipients.Add( _
                         Name:=objOriginalMsg.Recipients.Item(1).Name, _
       ' ... more error handling
        .Update ' save everything in the MAPI system
        .Send showDialog:=False
    End With
' ... error handling
End Function

See Also


Message Object