wissel.net

Usability - Productivity - Business - The web - Singapore & Twins

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 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
Calendar entries or todo were not part of the consideration, but that's just a question in what view you look. For "any" document it is ($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 on 21 November 2014 | Comments (4) | categories: IBM Notes

Comments

  1. posted by Lars Olufsen on Monday 24 November 2014 AD:
    Brilliant, Stephan. Thanks for sharing!
  2. posted by david on Tuesday 25 November 2014 AD:
    The problem with this approach is that if a spam, newsletter, or a group mail (sent to the whole company for example) has been received in this mailbox it will not be flagged as dormant. We wrote some code to identify inactive mailboxes by going through the db activity instead although that is not straight forward as we had to use API and run this from a machine with a notes client
  3. posted by Stephan H. Wissel on Tuesday 25 November 2014 AD:
    Yes. Incoming emails will keep that account alive. This is why the alternative of using the ($Sent) view is interesting.
  4. posted by Harris Huckabee on Saturday 23 July 2016 AD:
    Thanks, Stephan. I am using both $Sent and $All... I'll let the project people make the call on what they consider dormant.