Avatar of dwe0608
dwe0608
Flag for Australia

asked on 

vb.net - Outlook - Counting the number of items in a conversation

Merry Christmas guys ...

I am implementing a function will will return the number of items in an Outlook Conversation - I have cobbled the following together and whilst no error is thrown - it doesnt seem to return the correct count:

    Function GetConv(mailItem As Outlook.MailItem)
        Dim Conversation As Outlook.Conversation ' Get the conversation
        Dim Items As Outlook.SimpleItems
        Dim expMessage$

        '   // If Item = a MailItem.
        Try
            If TypeOf (mailItem) Is Outlook.MailItem Then
                Conversation = mailItem.GetConversation
                If Not IsNothing(Conversation) Then
                    Items = Conversation.GetChildren(mailItem)
                    GetConv = Items.Count
                End If
            Else
                GetConv = 0
            End If

        Catch ex As SystemException
            expMessage = ex.Message
            MsgBox(expMessage)
            GetConv = 0
        End Try

    End Function

Open in new window


Can someone assist to ensure that the correct count of the items in the conversation are returned?

MTIA

DWE
Visual Basic.NETOutlook

Avatar of undefined
Last Comment
dwe0608

8/22/2022 - Mon