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
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
only
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
document
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
Wend
'//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
errHandler:
Resume Next
End Sub
MEMBER FEEDBACK TO THIS TIP
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 SearchDomino.com 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.