Manage Learn to apply best practices and optimize your operations.

Message recall

This agent provides the ability to recall a message from the Domino domain. It's nice when someone sends a message with confidential information to the entire company.

View member feedback to this tip.

This agent provides the ability to recall a message from the Domino domain. It's nice when someone sends a message with confidential information to the entire company. You can quickly and easily remove the document from every mail file in the company. For large environments I would re-evaluate the removal just for server loads, possibly get the names from the memo and then just open those mail files for message removal. It's not perfect, but it works great in our environment.

  Code: Dim db As NotesDatabase, 
mailDb As NotesDatabase
 Dim s As New NotesSession
 Dim doc As NotesDocument
 Dim dc As NotesDocumentcollection
 Dim notesdbdir As New 
 Dim mailDoc As NotesDocument
 Dim thisLog As NotesLog
 counter = 0
 '//evaluate the membership of the 
administrators group.  If user does 
not have access, then exit the routine
 eval$ ={@IsMember("Administrators";
 admin = Evaluate(eval$)
 '//check security level of the person 
running the agent - admin level 
 If admin(0) = 0 Then
  Msgbox "You do not have the required 
access to recall 
messages.  Please contact your Lotus Administrator. 
 Thank you", 0+16, "Error - 
Security Level"
  Exit Sub  
 End If
 '//script will error if the mailDoc is not set, 
so force the script to 
resume next on any error
 On Error Goto errHandler
 '//get a handle to the current database
 Set db = s.CurrentDatabase
 '//get the first database in the directory on the server.
 Set mailDb = notesdbdir.getfirstdatabase(DATABASE)
 '//get the documented marked for removal
 Set dc = db.UnprocessedDocuments
 '//check to make sure that a message(s) 
has been selected for recall.  
If not, then exit sub
 If dc.count = 0 Then 
  Msgbox "You have not selected any 
messages to recall.  Please 
select the messages you wish to recall and 
run this agent again. Thank you.", 
0+16, "Error - No Message Selected"
  Exit Sub  
 End If
 '//Due to server performance, 
get only one document at a time 
 Set doc = dc.getfirstdocument
 '//set the log file using some
 information from the document
 Set thisLog = New NotesLog("Message Recall")
 Call thisLog.OpenNotesLog("server/ou", "applog.nsf")
 thisLog.LogActions = True
 '//log brief information about the 
offending email for tracking purposes
 Call thisLog.logaction
(" ********** RECALL STARTED ************* ") 
 Call thisLog.logaction(db.title & " - " 
& doc.universalid)
 '//check the database for the particular 
unid in question
 While Not(mailDb Is Nothing)
  '//if the filepath of the database 
has 'mail' in it, then it 
should be a mail file
  If Instr(mailDb.filepath,"mail") Then
   '//in order to search by unid, you
 must open an 
instance of the mail file
   Call mailDb.Open("", "")
   '//Search for the document by unid
   Set mailDoc = 
   '//if the document matching is found, 
remove the 
   If Not(mailDoc Is Nothing) Then
    Call mailDoc.Remove(True)
    Call thisLog.logaction("      -- document 
removed from db: " & mailDb.title)
    '//count the number of databases that we 
the document from, for verification purposes
    counter = counter + 1
   End If
  End If
  '//get the next database in the directory
  Set mailDb = notesdbdir.GetNextDatabase
 '//display message to the administrator
 Msgbox "Recall Complete.  
Please review log file for validation. Thank 
you and have a great day, " 
& s.commonusername,  0+64, "Message Recall"
 '//finish up the logging and then close the log file
 Call thisLog.LogAction
(" Agent Completed -- " & counter & " databases 
were accessed.")
 Call thisLog.logaction
(" ********** RECALL COMPLETE ************* ") 
 Call thisLog.Close
 Resume Next
End Sub


This code has major flaws and I have experienced it even before this was posted. The problem is when the message is delivered across the domain and different servers in the domain it doesn't maintain the same universal ID for the document. The universal document ID changes with no fixed rule.

—Ashok N.

Do you have comments on this tip? Let us know.

This tip was submitted to the tip exchange by member John Morehouse. Please let others know how useful it is via the rating scale below. Do you have a useful Notes/Domino tip or code to share? Submit it to our monthly tip contest and you could win a prize and a spot in our Hall of Fame.

Dig Deeper on Lotus Notes Domino Agents

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 ...