Afternoon all.

Been about 10 years since I last posted here for help, but here goes

I am creating a small snippet of code, that will sort my Inbox by sender. The view is that it will delete anythign other than the latest email in a given conversation. My goal is to reduce the number of ermails in my Inbox!!
I've nearly got it working, but need to sort by [Received] within [From], so I get the latest ones first. I don't know how to do that bit. I can do it manually, by holding down the Shift key, but that doesn't help me programatically, apart from letting me know it is somehow possible!

Can anyone help ?

Here is my code if you fancy a laugh (its been a long time since I coded anything!) ...

Code:
Sub DeleteOldMessages()
 Dim olItems As Outlook.Items
 Dim SubjectHeading As String
 Dim i As Long, j As Long
 
 ' Default folder to Inbox
 Set olItems = Session.GetDefaultFolder(olFolderInbox).Items
 
 ' Sort by sender
 olItems.Sort "[From]", True
 ' *** need to sort by time within sender, in order to get latest ones first.
 
 
 SubjectHeading = Trim$(olItems(1).Subject)
 For i = 2 To olItems.Count
     If Trim$(olItems(i).Subject) = SubjectHeading Then
        For j = olItems.Count To i + 1 Step -1
            If InStr(1, olItems(j).Subject, SubjectHeading) Then
                olItems.Item(j).Delete
            End If
        Next
     Else
        SubjectHeading = Trim$(olItems(i).Subject)
     End If
 Next i
 
 Set olItems = Nothing
 End Sub
Thanks all