Delete DEAD mail

This tip describes the procedure for deleting DEAD mail from your system.

Ever try putting a scheduled agent in the mail.box database to remove dead mail? It works for a day and then stops working because the scheduler does not recognize it due to the fact that it is an internal database. Because this doesn't work I created an agent to run from a normal database on the server.

This agent will loop through the mail boxes on the server and remove dead mail based on a specified selection formula. I built this selection formula by first creating a view in the mail.box database and putting in the specified formula. Once satisfied I moved this formula into my script code to use as a search string. You can schedule this agent as often as you would like and it should automatically keep your mail boxes clean. You will need to put it in a normal(.nsf) database and not the mail.box database otherwise the scheduler will not recognize it.


Option Public

Sub Initialize '=============================================================================================== 'Created by Pablo Herman(1stopdomino) on 8-27-2002 '=============================================================================================== 'This agent will loop through the mail boxes on the server and remove dead mail based on a 'specified selection formula I built this selection formula by first creating a view in the 'mail.box database and putting in the specified formula. Once satisfied I moved this formula 'into my script code to use as a search string. You can schedule this agent to run as often 'as you would like and it should automatically keep your mail boxes clean. You will need to 'put it in a normal(.nsf) database and not the mail.box database otherwise the scheduler will 'not recognize it. '===============================================================================================

 Dim s As New NotesSession
 Dim mbox As NotesDatabase
 Dim dc As NotesDocumentCollection
 
 '>>Establish the database list to process
 Redim dbarray(2) As String
 dbarray(0) = "mail1.box"
 dbarray(1) = "mail2.box"
 dbarray(2) = "mail3.box"
 
 '>>If you only have one mail.box then remark the above 4 lines and unremark the next 2 lines
 'Redim dbarray(0) As String
 'dbarray(0) = "mail.box"
 
 '>>Define search fomula
 sstring$ = "SELECT FORM = ""NonDelivery Report"" & @Contains(@UpperCase(FailureReason); " & _
 """USER ACCOUNT INACTIVE"" : ""NO SUCH USER"" : ""NOT LISTED IN PUBLIC"")"    
 '>>Loop through all databases and remove documents based on the search formula
 Forall d In dbarray
  '>>This can only run on the same server it is scheduled on therefore use we can only use ""
  Set mbox = s.GetDatabase("", Cstr(d))
  If mbox.isopen Then
   Set dc = mbox.Search(sstring$, Nothing, 0)
   Print "Found " & dc.count & " documents to delete in " & mbox.filename
   Call dc.RemoveAll(True)
  Else
          Print "Unable to open database " & Cstr(d)
  End If
 End Forall
 
End Sub
This was first published in September 2002

Dig deeper on Lotus Notes Domino Administration Tools

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com'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 ...

SearchEnterpriseLinux

SearchDataCenter

SearchExchange

SearchContentManagement

Close