Manage Learn to apply best practices and optimize your operations.

Housekeep Mail Agent

This agent will housekeep the mail database for all mail documents that are N
days old after it has reached the specified quota. Place it in the mail
template for the Design task to update.

Set the agent as a scheduled agent that runs on the server and signed it using
the server id.
This example shows that the agent which will delete those mail documents which
are 180 days old if the mail database is over the quota of 30 MB.

Variables "session" and "db" are declared in the Declaraton event.

Sub Initialize
(1) N days are defined in the RemoveMails function
(2) Mail database quota size are determined in the IsOverQuota function.
Set session = New NotesSession
Set db = session.CurrentDatabase
If IsOverQuota(30) Then
'N days = 180
Call RemoveMails(180)
End If
End Sub

Function IsOverQuota (iQuota As Integer)
'iQuota is in Megabytes
Dim quota As Long
Dim CurrSize As Double
Dim MaxSize As Double
CurrSize = Round (db.Size/1000000,2) 'Converts DB size to Megabytes
MaxSize = Cdbl(iQuota) ' Megabytes
If CurrSize> MaxSize Then
IsOverQuota = True
IsOverQuota = False
End If
End Function

Function RemoveMails (iMailAge As Integer)
'iMage Age is in number of days
Dim dateTime As New NotesDateTime ("1/1/97")
Dim strSearchFomula As String
Dim docCollection As NotesDocumentCollection
Dim strMailAge As String
'Convert the number days to string as Notes Formulae is formatted as string
strMailAge = Cstr(iMailAge)
strSearchFormula = "DeliveredDate < @Adjust(@Today;0;0;-" + strMailAge +
| PostedDate < @Adjust(@Today;0;0;-" + strMailAge + ";0;0;0) | @Created <
+ strMailAge + ";0;0;0)"
Set docCollection=db.Search(strSearchFormula, dateTime,0)
'Reomve the old documents
If docCollection.Count <> 0 Then
Call docCollection.RemoveAll(True)
End If
End Function

Dig Deeper on Domino Resources - Part 7

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.




  • iSeries tutorials's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...