OpenNTF.org - Clear the Recent Contacts
My Links (Not logged in)
Code Bin Search
 
Hosted by Prominic.NET
Rate This Code
5 - brilliant stuff
4 - very nice
3 - average
2 - needs work
1 - bad
   OpenNTF Code Bin
About This Code
Brief Description:
Clear the Recent Contacts 
Rating:
Rating: 4 , Number of votes: 1 
Contributor:
David J Montalvo 
Category:
Lotusscript 
Type:
Utilities 
Notes Version:
R8.x 
Last Modified:
03 Nov 2008 
OpenNTF Disclaimer

All of the program code and information presented in the OpenNTF.org Code Bin are provided "as-is", and should be used at your own risk. OpenNTF.org make no express or implied warranty about anything in the Code Bin, and OpenNTF.org will not be responsible or liable for any damage caused by the use or misuse of anything from this site. OpenNTF.org makes no guarantees about anything. Please thoroughly test all of the knowledge and code you find here before you attempt to use them in your production environment.

Code / Description
Here is a quick little code that I added to the R8 Mail template to quickly purge the Recent Contacts in R8. It removes the documents from the local NAB & clears the Metadata from the local PC.
Usage / Example
Dim vc As NotesViewEntryCollection

Dim RecentContactsDir As String
Dim db As NotesDatabase
Dim e As NotesViewEntry
Dim fileName As String
Dim s As NotesSession
Dim v As NotesView
Dim r As Integer

On Error Goto Errhandle

Set s = New NotesSession
Set db = s.GetDatabase("", "names.nsf")

If Not db.IsOpen Then
Messagebox "Unable to open your local Name & Address Book"

Else

Set v = db.GetView("(Recent Contacts)")
Set vc = v.AllEntries
Print "Deleting " & vc.Count & " 'Recent Contacts' "
Call vc.RemoveAll(True)

Print "Deleting 'Recent Contacts' Metadata"
RecentContactsDir = s.GetEnvironmentString( "Directory",True ) & "\workspace\.metadata\.plugins\com.ibm.notes.dip"

fileName$ = Dir$(RecentContactsDir & "\*.*", 0)
Do While fileName$ <> ""
Kill RecentContactsDir & "\" & fileName$
fileName$ = Dir$()
Loop

Msgbox "Completed deletion of 'Recent Contacts' & linked 'Metadata'. ",64,"Complete"

End If

Exit Sub

Errhandle:
Messagebox "Error" & Str(Err) & ": " & Error$,16,"Error: Use 'Alt + Print Screen' to capture this error"

 Comments
Posted by Mike Mortin on 11/03/2008 09:00:43 AMthis line no longer needed
Set view = db.GetView( "Main View" )
I have edited the document to remove it.
Posted by David J Montalvo on 11/03/2008 10:36:40 AMYou are correct
I have removed: Set view = db.GetView( "Main View" )
Thanks for pointing it out.
Posted by Qaiser Abbas on 01/06/2009 12:34:29 AMwhere should i add this code?
Where i add this code on my note template / mail.nsf.
waiting for your response.
Posted by David J Montalvo on 01/06/2009 05:01:29 PMCreate an Agent
Create a new LotusScript agent and simply cut and paste the code in. In the agent properties the trigger should be "On Event" + Action Menu Selection + Target "None".
Try to give the agent a name which sorts high on the "Actions" list. In my case all my agents are named "Administration\<agent Name>" so they all sort at the top of the list and group together.
Posted by Lori Bond on 02/08/2012 11:24:24 AMAdd to a button?
Sorry, very late to the game here, but I tried to add this code to a button and it wouldn't even run. If this is still monitored, can someone tell me if this can be tweaked for use in a button I can email to users?
 Add your comment!