I wrote the VBA code below as an answer to another post. You could easy
adapt it for your own purposes:-
Public Sub ScanAllFolders()
Dim objFolder As MAPIFolder
Dim lngItems As Long
Dim lngCounter As Long
Set objFolder =
Outlook.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Parent
Call ScanFolder(objFolder)
Set objFolder = Nothing
End Sub
Private Sub ScanFolder(objMAPIFolder As MAPIFolder)
Dim lngItems As Long
Dim lngCounter As Long
Dim objMailItem As MailItem
Dim objFolder As MAPIFolder
For Each objFolder In objMAPIFolder.Folders
Call ScanFolder(objFolder)
Next
For lngCounter = 1 To objMAPIFolder.Items.Count
If TypeName(objMAPIFolder.Items(lngCounter)) = "MailItem" Then
Set objMailItem = objMAPIFolder.Items(lngCounter)
If Instr(objMailItem.To,"(e-mail address removed)")>0 Then
Debug.Print objMailItem.SentOn, objMailItem.Subject
End If
Set objMailItem = Nothing
End If
Next
End Sub