Remove recent contacts from local names

  • 23 Feb, 2010

LotusScript button to remove individual names that have been cached in $users view of local address book. This script is from TN 139749

Sub Click(Source As Button)
        Dim sess As New NotesSession
        Dim db As NotesDatabase
        Dim view As NotesView
        Dim doc As NotesDocument
        Dim contact As String
        Dim tempInternetAddress As String
        Dim tempMailAddress As String
        Dim result As Integer
        Dim confirmResult As Integer

        ’ Getting local names.nsf
        Set db = sess.GetDatabase(“”,“names.nsf”,False)
        If db Is Nothing Then
                Messagebox “Unable to find local name.nsf.  Exiting…”
                Exit Sub
        End If
        ’ Getting recent contacts view
        Set view = db.GetView(“RecentCollaborators”)

        contact = “”
        ’ Prompting user for name
        contact = Lcase(Cstr(Inputbox(“Please input an internet address Notes adress, examples:” + Chr(13) + Chr(10) + “user@org.com or User/Org”)))
        If contact = “” Then
                Messagebox “You must enter in a value. Exiting…”
                Exit Sub
        End If

        ’ Getting first document in view
        Set doc = view.GetFirstDocument

        ’ If the document is of an smtp (internet address) then search the InternetAddress field other wise search the MailAddress (Notes Name) field
        If Instr(contact,“@”) Then
                While Not doc Is Nothing
                        tempMailAddress = “”
                        tempInternetAddress = “”
                        tempInternetAddress = Lcase(doc.InternetAddress(0))
                        If tempInternetAddress <> “” Then
                                If Instr(tempInternetAddress,contact) Then
                                        tempMailAddress = doc.MailAddress(0)
                                        result = Messagebox (“Do you want to delete user (” + tempMailAddress + “) with internet address (” + tempInternetAddress + “) or cancel serach?”,3 + 32)
                                        If result = 2 Then ’ Canceling Search
                                                Exit Sub
                                        Elseif result = 6 Then ’ Requesting deletion
                                                confirmResult = Messagebox (“Confirm deletion” , 4)
                                                If confirmResult = 6 Then ’ Confirm Deletion
                                                        Call doc.Remove(True)
                                                        Messagebox “Message deleted.  Exiting….”
                                                        Exit Sub
                                                End If
                                        Else ’ Otherwise continue search
                                                Print “Continuing to search….”
                                        End If
                                End If
                        End If
                        Set doc = view.GetNextDocument(doc)
                Wend
        Else
                Dim tempName As NotesName
                Set tempName = sess.CreateName(contact)
                contact = Lcase(tempName.Canonical)
                While Not doc Is Nothing
                        tempMailAddress = “”
                        tempInternetAddress = “”
                        tempMailAddress = Lcase(doc.MailAddress(0))
                        If tempMailAddress <> “” Then
                                If Instr(tempMailAddress,contact) Then
                                        tempInternetAddress = doc.InternetAddress(0)
                                        result = Messagebox (“Do you want to delete user (” + tempMailAddress + “) with internet address (” + tempInternetAddress + “) or cancel serach?”,3 + 32)
                                        If result = 2 Then ’ Canceling Search
                                                Exit Sub
                                        Elseif result = 6 Then ’ Requesting deletion
                                                confirmResult = Messagebox (“Confirm deletion” , 4)
                                                If confirmResult = 6 Then ’ Confirm Deletion
                                                        Call doc.Remove(True)
                                                        Messagebox “Message deleted.  Exiting….”
                                                        Exit Sub
                                                End If
                                        Else ’ Otherwise continue search
                                                Print “Continuing to search….”
                                        End If
                                End If
                        End If
                        Set doc = view.GetNextDocument(doc)
                Wend
        End If
End Sub

Related Posts

Migrating messages from Domino to Google using IMAP

  • 20 Feb, 2022

It's only for messages. No calendar migration Imapsync command is a tool allowing incremental and recursive imap transfers from one mailbox to another. If you don't understand the previous sentence,

Migrating messages from Domino to Google using IMAPRead More

Domino V12 and Verse 2.1 How to add a Photo URL

  • 08 Jun, 2021

Today i setup a Domino V12 server just for test some new features. A customer ask to use photos on Verse hosting photos on Domino. Domino V12 comes with Verse 2.0. I just download the version 2.1 of

Domino V12 and Verse 2.1 How to add a Photo URLRead More

Notes / Domino is forever

  • 04 Feb, 2021

Yesterday it seemed like it would be an ordinary working day but a client called me informing about the expiration of a certifier. It would be normal to resolve the problem with the re-certification p

Notes / Domino is foreverRead More