Dim db As New NotesDatabase("","names.nsf")
Dim logdb As New NotesDatabase("<server name>","ClearContactsLog.nsf")
Dim view As NotesView
Dim doc As NotesDocument
Dim doc2 As NotesDocument
Dim logdoc As NotesDocument
Dim session As New NotesSession
Dim stream As NotesStream
Dim filename As String
Dim Response As Integer
Dim dateTime As New NotesDateTime( "" )
Dim nam As NotesName
Dim ErrorMsg As String
Dim Status As String
Dim item As NotesItem
On Error Resume Next
' Store the name of the user running this
Set nam = session.CreateName(session.UserName)
' Store the current date and time
dateTime.LSLocalTime = Now
' Create the entry for the log
Set logdoc = logdb.CreateDocument()
locdoc.Form = "Log Entry"
' Set the view to clear for the local contacts
Set view = db.GetView("(Recent Contacts)")
If view.AllEntries.Count > 0 Then
Set doc = view.GetFirstDocument
Do While Not (doc Is Nothing)
Set doc2 = doc
Set doc = view.GetNextDocument(doc)
Call doc2.RemovePermanently(True)
Loop
End If
If view.AllEntries.Count > 0 Then
Response = Msgbox("The view was not cleared successfully!" + Chr(10) + Chr(13) + "Click on OK to return to Notes then contact the Help Desk.",0 + 48,"Error During Clearing of Recent Contacts ")
' Store what is to be saved in the log
ErrorMsg = "Error During Clearing of Recent Contacts "
Status = "View not cleared"
End If
' Now, add the parameter line to the NOTES.INI
filename = Left(db.FilePath, Len(db.FilePath) - 14) + "NOTES.INI"
Set stream = session.CreateStream
' Use name of text file as subject
If Not stream.Open(filename, "ASCII") Then
Response = Msgbox("The process was aborted!" + Chr(10) + Chr(13) + "Click on OK to return to Notes then contact the Help Desk.",0 + 48,"Error During Clearing of Recent Contacts ")
' Store what is to be saved in the log
ErrorMsg = "Error During Clearing of Recent Contacts "
Status = "Cannot open INI file"
Exit Sub
Else
' Write the correct line to the bottom of the NOTES.INI
stream.WriteText "DisableDPABProcessing=1" + Chr(10) + Chr(13)
Response = Msgbox("The process has completed." + Chr(10) + Chr(13) + "Click on OK to return to Notes then close Notes and re-open it.",0 + 64,"Clearing of Recent Contacts Completed")
' Store what is to be saved in the log
Status = "Success"
End If
' Write this information to the log file
Call logdoc.AppendItemValue("A$LOGTIME",Cdat(dateTime.DateOnly + " " + dateTime.TimeOnly))
Call logdoc.AppendItemValue("A$PROGNAME", "Clearing of Recent Contacts ")
Call logdoc.AppendItemValue("A$USER", nam.Common)
Call logdoc.AppendItemValue("A$ACTION", Status)
If ErrorMsg > "" Then
Call logdoc.AppendItemValue("A$ERRMSG", ErrorMsg)
End If
Call logdoc.Save(True,False)