CreateConversationIndex Method (Session Object)

CreateConversationIndex Method (Session Object)

The CreateConversationIndex method creates or updates an index for a conversation thread.

Syntax

newIndex = objSession.CreateConversationIndex( [ParentIndex] )

newIndex

String. The conversation index to be assigned to the first or next message in the thread.

objSession

Required. The Session object.

ParentIndex

Optional. String. The conversation index of a received message for which a reply is being generated.

Remarks

The CreateConversationIndex method takes the current value of a conversation index and returns a new value suitable for an outgoing message. If the message to be sent represents the beginning of a new thread, there is no current index, and the ParentIndex parameter is not passed in. If the outgoing message is a reply to a received message, the ConversationIndex property of the received message is passed in as the ParentIndex parameter.

The CreateConversationIndex method ultimately calls the MAPI ScCreateConversationIndex function.

Example

This code fragment responds to the first message in the Inbox:

Dim objInMsgColl As Messages ' messages in Inbox
Dim objRecMsg As Message     ' received message
Dim objNewMsg As Message     ' outgoing reply message
Dim objRcpColl As Recipients ' recipients for outgoing message
Dim strSenderID As String    ' unique ID of original sender
Dim strCnvIndx As String     ' conversation index

If objSession Is Nothing Then
    MsgBox "Must first create MAPI session and log on"
    Exit Function
End If
Set objInMsgColl = objSession.Inbox.Messages
' ... error handling ...
If objInMsgColl Is Nothing Then
    MsgBox "Could not successfully access Inbox messages"
    Exit Function
End If
Set objRecMsg = objInMsgColl.GetFirst()
If objRecMsg Is Nothing Then
    MsgBox "No messages in Inbox"
    Exit Function
End If
' make new conversation index from old
strCnvIndx = objSession.CreateConversationIndex _
                        (objRecMsg.ConversationIndex)
strSenderID = objRecMsg.Sender.ID ' save senders unique ID
Set objNewMsg = objSession.Outbox.Messages.Add ' generate reply
' ... error handling ...
Set objRcpColl = objNewMsg.Recipients
' ... error handling ...
objRcpColl.Add entryID:=strSenderID ' add sender as recipient
' ... error handling ...
With objNewMsg
    .ConversationIndex = strCnvIndx
    .ConversationTopic = objRecMsg.ConversationTopic
    .Subject = "RE: " & objRecMsg.Subject
    .Text = "Please consider this a reply to your message."
    .Update' save everything in the MAPI system
    .Send showDialog:=False
End With
 

See Also

Concepts

Session Object