Saya telah mencari sesuatu yang serupa. Saya harus menggunakan makro karena arsip otomatis dinonaktifkan untuk instalasi saya. Inilah yang saya pikirkan:
Option Explicit
Private Sub Application_MAPILogonComplete()
' this runs on app startup
Const MSG_AGE_IN_DAYS = 7
Dim oFolder As Folder
Dim oFilteredItems As Outlook.Items
Dim oItem As MailItem
Dim oDate As Date
oDate = DateAdd("d", -MSG_AGE_IN_DAYS, Now())
oDate = Format(oDate, "mm/dd/yyyy")
' you can use this command to select a folder
'Set oFolder = Application.Session.PickFolder
Set oFolder = Me.Session.Folders.GetFirst
' shows all the folder names
'For Each fldr In oFolder.Folders
' Debug.Print fldr.Name
'Next fldr
' this was the sub-folder I wanted to cleanup.
Set oFolder = oFolder.Folders("Storage").Folders("batch runs")
Debug.Print "checking " & oFolder.FolderPath
Debug.Print "for msgs older than " & oDate
' you can modify the filter to suit your needs
Set oFilteredItems = oFolder.Items.Restrict("[Received] <= '" & oDate & "' And [Unread] = True")
Debug.Print "removing " & oFilteredItems.Count & " items"
While oFilteredItems.Count > 0
Set oItem = oFilteredItems.GetFirst
Debug.Print " " & oItem.UnRead & " " & oItem.Subject
' the remove method permanently deletes the item.
oFilteredItems.Remove 1
'Debug.Print oFilteredItems.Count & " items left"
Wend
Debug.Print ". end"
Set oFolder = Nothing
Set oFilteredItems = Nothing
Set oItem = Nothing
End Sub
Makro ini melekat pada fase terakhir dari siklus hidup aplikasi; ini berjalan ketika Outlook mulai. Anda mungkin juga ingin menandatanganinya (dan mempercayai tanda tangan Anda) sehingga Anda mendapatkan keluhan keamanan.
HTH