Purges a single db based upon user input. Only purges mail. Does not purge calendar entries, etc.
Sub Initialize
Msgbox "This agent will purge mail older than the amount of time you specify, in whichever database you specify.", , "Notice."
On Error Goto handler
Dim docdate As NotesDateTime
Dim datetime As New NotesDateTime("")
Call datetime.SetNow
Call DateTime.AdjustDay(-( Inputbox$("Please enter the amount of days you want to purge back from. For example, if you want to purge all mail older than 30 days, enter 30")))
Set docdate=New NotesDateTime("")
Dim db As New NotesDatabase( ( Inputbox$("Which Server?")), ( Inputbox$("Which database? Please include the path and filename relative to the data directory. e.g. <mail\test.nsf>")) )
Print "Beginning purge of " & db.Title
d=0
k=0
Dim doc As NotesDocument
Dim view As notesview
Set view = db.getview("($All)")
Set doc = view.GetFirstDocument
While Not ( doc Is Nothing )
form = doc.form(0)
docdate.LSLocalTime=doc.Created
Set nextdoc =view.GetNextDocument(doc)
If form = "Memo" And datetime.TimeDifference(docdate)>0 Then
Call doc.remove (True)
d=d+1
Elseif form = "Reply" And datetime.TimeDifference(docdate)>0 Then
Call doc.remove (True)
d=d+1
Elseif form = "Reply With History" And datetime.TimeDifference(docdate)>0 Then
Call doc.remove (True)
d=d+1
Elseif form = "" And datetime.TimeDifference(docdate)>0 Then
Call doc.remove (True)
d=d+1
End If
k=k+1
Set doc = nextdoc
Wend
Msgbox "Finished processing " & db.Title & "." & " Processed " & k & " " & "documents." & " " & " DELETED " & d & " documents.", , "Results"
handler:
If Erl() <> 0 Then
Print "Got error " & Error$ & " on line " & Cstr(Erl)
Resume Next
End If
End Sub