I wrote code below that is very similar to the accepted answer here. It marks emails and meeting responses as read and moves them to the archive.
I sort my mail by newest on top. After using the macro, the selection defaults to the next email down (the older one). I want it to move to the next email up (the newer one). If I reverse the sorting order of emails, then it works how I want it to. I’ve dedicated too much time to this to just reverse the sorting order of my emails.
I tried to set a MailItem to Application.ActiveExplorer.CurrentFolder.Items.GetNext then use MailItem.Display. This opens rather than changes selection, doesn’t know current selection, can’t figure out what’s considered “next”.
I tried setting the Application.ActiveExplorer.Selection.Item property. I’ve been through (MSDN and Expertsexchange) looking for a solution.
Sub MoveToArchive()
On Error Resume Next
Dim objFolder As Outlook.MAPIFolder
Dim objNS As Outlook.NameSpace, objItem As Outlook.MailItem
Dim objMRItem As Outlook.MeetingItem
Set objNS = Application.GetNamespace("MAPI")
Set objFolder = objNS.Folders("Archive").Folders("Inbox")
If Application.ActiveExplorer.Selection.Count = 0 Then
Exit Sub
End If
For Each objItem In Application.ActiveExplorer.Selection
If objFolder.DefaultItemType = olMailItem Then
If objItem.Class = olMail Then
objItem.UnRead = False
objItem.Move objFolder
End If
End If
Next
For Each objMRItem In Application.ActiveExplorer.Selection
If objFolder.DefaultItemType = olMailItem Then
If objItem.Class = olMeetingResponsePositive Or olMeetingResponseNegative Or olMeetingResponseTentative Then
objMRItem.UnRead = False
objMRItem.Move objFolder
End If
End If
Next
Set objItem = Nothing
Set objMRItem = Nothing
Set objFolder = Nothing
Set objNS = Nothing
End Sub
Outlook provides no way to programmatically select a particular item in the Explorer window.
So you would be able to do it this way. The only way I think that you could do it would be to programmatically press the previous key on the tool bar or menu. or redesgin the app to archive in the inspector etc.