I'm looking someting like that but with one step further
is it possible to delete every item in folder and its subfolder
ex:
\\pstname\Inbox\Fred\[ALL]subFolder
assuming that there are a lot of subs and they can possibly change
so I want the script able to look all sub folders in a dynamical way
OutlookVBA
Last Comment
Physimed
8/22/2022 - Mon
Qlemo
That's a bit more complex, as we have to implement a recursive procedure for that. You'll call the changed sub DeleteOlderThan1day again:
Sub DeleteOlderThan1day() Call DeleteOlderInSub(Application.Session.Folder("pstname").Folders("Inbox").Folders("Fred"), DateAdd("d", -1, Now())End SubSub DeleteOlderInSub(oFolder as Folder, oldDate as Date)Dim oSubfolder as FolderDim ItemsOverMonths As Outlook.Items Set ItemsOverMonths = oFolder.Items.Restrict("[Received] <= """ & Format(oldDAte, "mm/dd/yyyy") & """") For i = ItemsOverMonths.Count To 1 Step -1 ItemsOverMonths.Item(i).Delete Next For Each oSubFolder In oFolder.Folders DeleteOlderInSub(oSubFolder, oldDate) Next Set ItemsOverMonths = NothingEnd Sub
Open in new window