Last usage of a mail file - for all users
My admin is getting a little rusty. When I was asked: " How can I indentify a dormant mailbox?" I couldn't name a place in admin where to look. Of course, there is the
As usual YMMV
NotesDatabase.LastModified
property, but that would get updated on a design refresh too. So I asked innocently: " dormant, how?" After an amusing 2 hour discussion between the stake holders (only the popcorn was missing) we concluded that it is either
- No document has been created for a while (including incoming)
- No email has been sent for a while
($All)
and for sent documents ($Sent)
. The LotusScript code is just a few lines. I needs to be run, so it can access all mailboxes.You can do that in Full-Admin mode or run it with the server id. Important: all servers need to be reachable. Of course the code could be modified to run on the current server only and to send a (MIME) message instead of writing a file. Anyway here you go:
Option Public
Option Declare
Sub Initialize
Dim s As New NotesSession
Dim allAdr As Variant
Dim out As NotesStream
Dim nab As NotesDatabase
Set out = s.Createstream()
'change this - you could write into
'an eMail or a database or or or
out.Open("report.csv")
allAdr = s.Addressbooks
ForAll oneDB In allAdr
Set nab = oneDB
Call recordUsers(out, nab)
End ForAll
Call out.Close()
End Sub
Sub recordUsers(out As NotesStream, nab As NotesDatabase)
On Error GoTo Err_recordUsers
Dim userView As NotesView
Set userView = nab.Getview("People")
If userView Is Nothing Then
Call out.Writetext("No user view in "+nab.Filepath, EOL_PLATFORM)
GoTo Exit_recordUsers
End If
Dim doc As NotesDocument
Dim MailServer As String
Dim MailFile As String
Dim FullName As String
Set doc = userView.Getfirstdocument()
Do Until doc Is Nothing
'Check for the fields
If doc.Hasitem("FullName") Then
FullName = doc.Getitemvalue("FullName")(0)
If Not doc.Hasitem("MailServer") Or Not doc.Hasitem("MailFile") Then
Call out.Writetext("No entry for user "+fullName)
Else
MailServer = doc.Getitemvalue("MailServer")(0)
MailFile = doc.Getitemvalue("MailFile")(0)
Call out.Writetext(fullName+", ",EOL_NONE)
Call fetchLastDocumentDate(out, MailServer, MailFile)
End If
End If
Set doc = userView.Getnextdocument(doc)
Loop
Exit_recordUsers:
Exit Sub
Err_recordUsers:
MsgBox Error$
Resume Exit_recordUsers
End Sub
Sub fetchLastDocumentDate(out As NotesStream, MailServer As String, MailFile As String)
Dim s As New NotesSession
Dim nsf As NotesDatabase
Dim v As NotesView
Dim doc As NotesDocument
Set nsf = s.Getdatabase(MailServer, MailFile)
If Not nsf.Isopen Then
Call nsf.Open("", "")
End If
If Not nsf.Isopen Then
Call out.Writetext("can't open "+MailFile, EOL_PLATFORM)
Else
Set v = nsf.Getview("$All") 'Change this if your definition of dormant is different
Set doc = v.Getlastdocument()
Call out.Writetext(CStr(doc.Created), EOL_PLATFORM)
End If
Exit_fetchLastDocumentDate:
Exit Sub
err_fetchLastDocumentDate:
Call out.Writetext(Error$, EOL_PLATFORM)
Resume Err_fetchLastDocumentDate
End Sub
As usual YMMV
Posted by Stephan H Wissel on 21 November 2014 | Comments (4) | categories: IBM Notes