I have the following macro to search all my email accounts but I'd like to exclude the Deleted Items folder. I thought there might be a way to filter it in my text search statement but wasn't successful. After a couple hours I thought I might be able to do it by setting a category and filtering not to include that category. I must be over looking something but this seems like overkill. So continuing with this category thought, I would like to create a macro to set the category of items that arrive in the Deleted Items folder to 'Deleted' then I would just add "& NOT category: (Deleted)" to my txtSearch variable. My current macro below...
Sub LastSevenDays()
Dim myolApp As New Outlook.Application
Dim tDate As Date
tDate = Now - 7
txtSearch = "received: (" & Format(tDate, "mm/dd/yyyy") & ".." & Format(Now, "mm/dd/yyyy") & ")"
myolApp.ActiveExplorer.Search txtSearch, olSearchScopeAllFolders
Set myolApp = Nothing
End Sub
Any assistance would be greatly appreciated. Thank you
Sub LastSevenDays()
Dim myolApp As New Outlook.Application
Dim tDate As Date
tDate = Now - 7
txtSearch = "received: (" & Format(tDate, "mm/dd/yyyy") & ".." & Format(Now, "mm/dd/yyyy") & ")"
myolApp.ActiveExplorer.Search txtSearch, olSearchScopeAllFolders
Set myolApp = Nothing
End Sub
Any assistance would be greatly appreciated. Thank you