(Declarations)
Dim session As NotesSession
Dim db As NotesDatabase
Dim FILE_DIR As String
Dim MAIL_DIR As String
Dim SENDTO As String
Sub Initialize
Dim maildb As NotesDatabase
Dim view As NotesView
Dim maildoc As NotesDocument
Dim rtitem As NotesRichTextItem
Dim file_path As String
Dim file_name As String
Dim result() As String
Dim i As Integer
Dim msg As String
On Error Goto catch
Set session = New NotesSession
Set db = session.CurrentDatabase
FILE_DIR = "C:\Lotus\Domino\Data\mail\"
MAIL_DIR = "mail\"
file_path = FILE_DIR + "*.nsf*"
' list of all .nsf files in the FILE_DIR
file_name = Dir$(file_path, 0)
SENDTO = "admin/iba"
i = -1
Do While file_name <> ""
Set maildb = session.GetDatabase(db.Server, MAIL_DIR + file_name, False)
If Not maildb Is Nothing Then
If Not maildb.CurrentAccessLevel < ACLLEVEL_READER Then
Set view = maildb.GetView("($Sent)")
Call view.Refresh
Set maildoc = view.GetLastDocument
If Not maildoc Is Nothing Then
i = i + 1
Redim Preserve result(i)
result(i) = maildb.FilePath + "': " + Cstr(maildoc.PostedDate(0))
End If
Else
Call SendAdminLog("Ошибка доступа: " + FILE_DIR + file_name, SENDTO)
End If
End If
file_name = Dir$()
Loop
' send result() to SENDTO
If Not i = -1 Then
msg = Join(result, Chr(10))
Call SendAdminLog(msg, SENDTO)
End If
Exit Sub
catch:
Call ErrorProcess()
End
Resume Next
End Sub
Sub SendAdminLog(msg As String, sendto As String)
Dim maildoc As NotesDocument
Dim rtitem As NotesRichTextItem
On Error Goto catch
Set maildoc = New NotesDocument(db)
maildoc.Form = "Memo"
maildoc.Subject = db.Title + " application administration log message "
maildoc.SendTo = sendto
maildoc.Principal = db.Title + " application"
Set rtitem = New NotesRichTextItem(maildoc, "Body")
Call rtitem.AppendText(msg)
Call maildoc.Send(False)
Exit Sub
catch:
End
Resume Next
End Sub
Sub ErrorProcess()
On Error Goto catch
Call SendAdminLog(|Agent "| + agent.Name + |" error:| + Ustring(2, Chr(10)) + |Error #| + Cstr(Err) + | in line | + Cstr(Erl) + |: | + Error$() + |.|, SENDTO)
Exit Sub
catch:
End
Resume Next
End Sub