I have a mail-in database that acts as a secure “holdbox” for all incoming mail, so if a user deletes something important, I can retrieve it for them from this database within 30 days. I don’t want the database getting huge, so I set up archiving to delete documents not modified within 30 days, but the archiving is not deleting documents older than 30 days…is there another way to do this?
Subject: aut-delete mail after 30 days
I wrote this agent to do just that - hope it works for you:
'globals
Dim Continue As Integer
Dim ThisSession As NotesSession
Dim ThisDatabase As NotesDatabase
Dim ArchDatabase As NotesDatabase
Dim ArchView As NotesView
Dim UNIDView As NotesView
Dim WeArchiveThisDoc As Integer
Dim CutOffDate As NotesDateTime
Sub Initialize
Dim AgStartTime As New NotesDateTime(Now)
Dim AgTotalRunTime As Long
ArchInit
If Continue Then
ArchDocs
End If
Print "Finished running custom archive agent at: " + Cstr(Now)
Dim AgEndTime As New NotesDateTime(Now)
AgTotalRunTime = AgEndTime.TimeDifference(AgStartTime)
Print "Custom archive agent took: " + Cstr(AgTotalRunTime) + " seconds to run."
End Sub
Sub ArchInit
Continue = False
Dim ArchSettings As NotesView
Dim ArchSettingsDoc As NotesDocument
Set ThisSession = New NotesSession
If ThisSession Is Nothing Then Exit Sub
Set ThisDatabase = ThisSession.CurrentDatabase
If ThisDatabase Is Nothing Then Exit Sub
Set ArchView = ThisDatabase.GetView("($All)")
If ArchView Is Nothing Then Exit Sub
Set CutOffDate = New NotesDateTime( Today)
Call CutOffDate.AdjustDay(-30)
Print "Started running custom archive agent at: " + Cstr(Now)
Continue = True
End Sub
Sub ArchDocs
Dim ArchDoc As NotesDocument
Dim NextArchDoc As NotesDocument
Dim ArchCount As Long
Set ArchDoc = ArchView.GetFirstDocument
Do Until ArchDoc Is Nothing
CheckDoc ArchDoc
If WeArchiveThisDoc Then
Set NextArchDoc = ArchView.GetNextDocument(ArchDoc)
Call ArchDoc.Remove(True)
Set ArchDoc = NextArchDoc
ArchCount = ArchCount + 1
If Right(Cstr(ArchCount), 2) = "00" Then
Print "Deleting document #: " + Cstr(ArchCount)
End If
Else
Set ArchDoc = ArchView.GetNextDocument(ArchDoc)
End If
Loop
End Sub
Sub CheckDoc(ArchDoc As NotesDocument)
Dim CreatedDate As New NotesDateTime( ArchDoc.Created)
WeArchiveThisDoc = False
If CreatedDate.LSLocalTime > CutOffDate.LSLocalTime Then
WeArchiveThisDoc = False
Else
Stop
WeArchiveThisDoc = True
End If
End Sub
Subject: RE: aut-delete mail after 30 days
That looks like it’ll work perfectly! Now I just need to work on scheduling it. Thanks a bunch!
Subject: aut-delete mail after 30 days
Mike,
Another solution is to set soft deletions in their mail files for 720 hours. This means that when someone deletes mail, it’ll stick around in their trash for 30 days!
This is what I do …
raphael
Subject: What archive settings are you using?