I am new to VBA and have searched for a macro to delete all existing out
of office replies in Outlook 2007. What would be a good macro to use?
Out-of-office replies can be deleted if you can describe a way to
identify them. In my experience, that is not reliably possible. If you
sort the message list by subject, those messages should appear together
and can then easily be deleted manually.
The following code should get you started; it will delete all messages
in the current folder whose subject line starts with "Out of Office".
Option Explicit
Sub DelOutOfOffice()
Dim lngItems As Long
Dim i As Long
Dim lngDels As Long
lngDels = 0
With ActiveExplorer.CurrentFolder
lngItems = .Items.Count
For i = lngItems To 1 Step -1
If Left(.Items(i).Subject, 13) = "Out of Office" Then
Debug.Print .Items(i).Subject
.Items(i).Delete
lngDels = lngDels + 1
End If
Next i
End With
MsgBox lngDels & " items deleted.", vbOKOnly + vbInformation, _
"DelOutOfOffice"
End Sub