Lotus Notes FAQ Visit Our Sponsor!

Can users recall messages they've sent?

Gregg Eldred provided the nice agent below to do this. Caveats are that the user must ask an administrator to run the agent and the administrators have to have access to everyone's mail file. A copy of the sent message must be selected for the agent to run on:

Sub Initialize
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 NotesDbDirectory("mailserver/ou")
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";@UserNamesList)}
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 = mailDb.GetDocumentByUNID(doc.UniversalID)
'//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 remove 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

Applies to Notes Versions: 4 4.5 4.6 5 6 6.5 7
Last Modified: March 14, 2005