Wednesday, May 30, 2012

Clear Lotus Notes "Recent Contacts" List

Do you have Lotus Notes 8.x and don't want to have contacts in your user's Recent Contacts list?  You can turn this off but maybe you just want to clear it to see if there is an issue.  Instead of trying to walk your users through deleting the information, just send them a button that says "Click Here" with the below Lotus Script code:


%REM
    Agent Remove Recent Contacts   
    Description: Clear recent contacts with just a click
%END REM

Option Declare
Sub Click(Source As Button)
    Dim ses As New NotesSession
    Dim v As NotesView
    Dim col As NotesViewEntryCollection
    Dim entry As NotesViewEntry       
    Dim doc As NotesDocument   
    Dim x As Integer
    x = 0
    ' For The Current User in The Current Session, Get All The NABs
    Forall books In ses.addressbooks
        'Check If The Current NAB is Private or Public
        'If The NAB Is Private, Then It Should Be Your Personal NAB
        If books.isprivateaddressbook Then
            'Verify if The NAB is Open, If Not, Open it
            If Not(Books.isopen) Then
                Call Books.open("",books.filename)
            End If
            Set v = books.getview("RecentCollaborators")
            Set col = v.AllEntries
            Set entry = col.GetFirstEntry()
            While Not(entry Is Nothing)
                Set doc = entry.Document
                doc.Remove(True)
                x = x + 1
                Set entry = col.GetNextEntry(entry)
            Wend           
            Print "Removed " & x & " Recent contacts"           
        End If
    End Forall
End Sub

1 comment:

Richard Him said...

Do you mind to guide me on steps to create the button in the email itself? Thanks