' this sub crawls though the DBDirectory of a server looking for mail files that inherit from specific mail templates. ' if found, it will find the trash and delete it (thus freeing up a little space) ' make sure that this script is run signed by id that has access to all mail files; otherwise, it will error out and quit and not process all dbs Dim s As New NotesSession Dim thisDb As NotesDatabase ' current db Dim dbDir As NotesDbDirectory ' list of dbs on server Dim db As NotesDatabase ' current db in dirDb being processed Dim templatenm As String ' mail template of db (if mail db) Dim tV As NotesView ' trash folder in current db Dim tCol As NotesViewEntryCollection ' all docs in trash folder Dim dbsizedelta As Long ' size savings from trash and compaction On Error Goto ErrorHandler ' setup environment Set thisDb = s.CurrentDatabase Set dbDir =s.GetDbDirectory(thisDb.Server) ' get first db and loop Set db=dbDir.GetFirstDatabase(1247) While Not (db Is Nothing) ' check design for mail template templatenm = db.DesignTemplateName Select Case templatenm Case "inotes6.ntf", "mail6.ntf", "mail6ex.ntf", "mail5.ntf", "mail5ex.ntf", "mail8.ntf", "mail7.ntf", "iNotes5", "iNotes5.ntf", "StdR6Mail" ' is mail file, get trash and empty it ... ' open db If( Not db.IsOpen) Then ' open it Call db.Open("","") If (db.IsOpen) Then ' can proceed... ' get trash folder Set tV = db.GetView("($Trash)") If Not (tV Is Nothing) Then ' have trash view, get any docs Set tCol=tV.AllEntries If (tCol.Count > 0) Then ' one or more docs were in trash Call tCol.RemoveAll(True) dbsizedelta = db.CompactWithOptions("BLS1K") ' B-File size reduction, S1K, compact if savings=>1K Print "Compacted db, " & db.FilePath & ", size change: " & Cstr(dbsizedelta) Else Print "No trash in db, " & db.FilePath & "." End If End If ' done this db Else ' give up, do nothing Print "Could not open db, " & db.FilePath & "." End If End If Case Else ' skip, do nothing Print db.FilePath & " is not a mail db." End Select SkipDb: ' loop Set db = dbDir.GetNextDatabase() Wend Print "done." Exit Sub ErrorHandler: Print "(Initialize) Unexpected Error. Info: " & Str(Err) & ": " & Error$ & " on line: " & Cstr(Erl) Resume SkipDb