Declare PtrSafe Function SetTimer Lib "user32" (ByVal hwnd As LongLong, ByVal nIDEvent As LongLong, ByVal uElapse As LongLong, ByVal lpTimerfunc As LongLong) As LongLong Declare PtrSafe Function KillTimer Lib "user32" (ByVal hwnd As LongLong, ByVal nIDEvent As LongLong) As LongLong Public TimerID As LongLong 'Need a timer ID to eventually turn off the timer. If the timer ID <> 0 then the timer is running Public Sub TriggerTimer(ByVal hwnd As LongLong, ByVal uMsg As LongLong, ByVal idevent As LongLong, ByVal Systime As LongLong) 'MsgBox "The TriggerTimer function has been automatically called!" Call DeleteEmail End Sub Public Sub DeactivateTimer() Dim lSuccess As LongLong lSuccess = KillTimer(0, TimerID) If lSuccess = 0 Then MsgBox "The timer failed to deactivate." Else TimerID = 0 End If End Sub Public Sub ActivateTimer(ByVal nMinutes As LongLong) nMinutes = nMinutes * 1000 * 60 'The SetTimer call accepts milliseconds, so convert to minutes If TimerID <> 0 Then Call DeactivateTimer 'Check to see if timer is running before call to SetTimer TimerID = SetTimer(0, 0, nMinutes, AddressOf TriggerTimer) If TimerID = 0 Then MsgBox "The timer failed to activate." End If End Sub Public Sub DeleteEmail() Dim ol As Outlook.Application Set ol = New Outlook.Application Dim olNs As Outlook.NameSpace Set olNs = ol.GetNamespace("MAPI") Dim fldr As Outlook.MAPIFolder Set fldr = olNs.GetDefaultFolder(olFolderDeletedItems) ' Target folder is Deleted Items. 'Dim emailCount As Integer 'emailCount = fldr.Items.Count Dim olMail As Outlook.MailItem 'MsgBox ("Count: " + CStr(emailCount)) 'MsgBox ("Purge Date: " + CStr(Now - 7)) Dim c As LongLong For c = fldr.Items.Count To 1 Step -1 If (TypeOf fldr.Items(c) Is MailItem) Then ' **Note: Indicate the number of days items will remain in Deleted Items folder before deleting, 7 is the current value. If (fldr.Items(c).ReceivedTime < Now - 7) Then fldr.Items(c).Delete End If End If Next c End Sub