You should process Activeinspector.CurrentItem not the selection. The code in that link will behave differently than expected if you, say leave mail open, make other selections in the explorer window, come back to the original mail which is now not selected.
To go to the next item after deleting, try simulating a click on the delete button.
Both these ideas are demonstrated in this answer.
Sub SetEditMode()
Dim myItem As Outlook.MailItem
Dim objInsp As Outlook.Inspector
Dim objActionsMenu As Office.CommandBarControl
Dim olNewMailItem As Outlook.MailItem
On Error Resume Next ' Bad coding do not do this
Select Case TypeName(Application.ActiveWindow)
Case "Explorer"
Set myItem = ActiveExplorer.Selection.Item(1)
myItem.Display
Case "Inspector"
Set myItem = ActiveInspector.CurrentItem
Case Else
End Select
If myItem Is Nothing Then GoTo ExitProc
'edit mode
Set objInsp = ActiveInspector
objInsp.CommandBars.ExecuteMso ("EditMessage")
objActionsMenu.Execute
ExitProc:
End Sub
Use this idea to refer to your mail.
Set myItem = ActiveInspector.CurrentItem
Use this idea to click a button.
objInsp.CommandBars.ExecuteMso ("EditMessage")
EditMessage is an Mso ID / Control ID. You can find the Mso ID for the Delete button by hovering over the icon where you add buttons to the Quick Access toolbar or a ribbon.
You can download a list here 2007 Office System Document: Lists of Control IDs
Edit: 2016-02-22
Control ID may not work as I thought. Use the hover technique.
Sub Reply_ExecuteMso_DeleteOriginal()
'
' ** NOT working as intended **
'
' Simulating clicking the delete button is too fast
' Must slow down with a MsgBox
'
' Now it is the same as clicking delete manually
'
Dim olItem As Object
Dim olReply As mailItem
Dim objInsp As Inspector
Select Case TypeName(Application.ActiveWindow)
Case "Explorer"
Set olItem = ActiveExplorer.Selection.Item(1)
olItem.Display
Case "Inspector"
Set olItem = ActiveInspector.currentItem
End Select
If olItem Is Nothing Then GoTo ExitProc
If olItem.Class = olMail Then
Set olReply = olItem.Reply
olReply.Display
olReply.HTMLBody = "Thank you!" & vbCrLf & olReply.HTMLBody
olReply.send
olItem.Display
Set objInsp = ActiveInspector
objInsp.CommandBars.ExecuteMso ("Delete")
End If
MsgBox "This slows down the processing."
On Error Resume Next
' Error when no items left
Set olItem = ActiveExplorer.Selection.Item(1)
olItem.Display
On Error GoTo 0
ExitProc:
Set olItem = Nothing
Set olReply = Nothing
Set objInsp = Nothing
End Sub