The advantage of relying on the “person” documents contained in the iNotes
(Domino Web Access, DWA) mailfile instead of those in the personal
addressbook on a Notes workstation, is that they travel with the mailfile,
i.e. They replicate with mail and calendar documents. I have stopped using the
address book synchronization, as I recently explained. Instead, a small
agent removes existing addresses in the PNAB and copies those from the
mailfile. Before continuing, you ought to create a backup of the personal
address book (file, database, new copy) Create a new Lotusscript agent as
follows: And copy this script into it
Sub Initialize
' Reload PNAB from mailfile people, destroying target documents
Dim s As New NotesSession
Dim maildb As NotesDatabase
Dim ws As New NotesUIWorkspace
Dim askme As Variant
Dim doc As NotesDocument
Dim user As String
Dim msg As String
Dim ndocs As Integer
Dim n As Integer
user = s.UserName
Set maildb = s.CurrentDatabase
Dim CalendarProfile As NotesDocument
Set CalendarProfile = maildb.GetProfileDocument("CalendarProfile")
If user <> CalendarProfile.owner(0) Then
Messagebox "This is not your mailfile. Will not do restore!", 16, "PNAB"
Exit Sub
End If
Set maildb = s.CurrentDatabase
Dim pnab As New NotesDatabase( "", "names.nsf" )
If Not pnab.IsOpen Then
Messagebox( "Can't open PNAB (names.nsf): Stop" )
Exit Sub
End If
Dim collection As NotesDocumentCollection
Dim selection As String
Dim formula As String
' Find and remove all Person & Group documents in current names.nsf
formula = "Form = ""Person"" | Form = ""Group"" "
Set collection = pnab.Search( formula, Nothing, 0 )
If collection.Count > 0 Then
msg = "The current Personal Address Book has " & _
collection.Count & " documents which need to be deleted. Is it OK to delete these?"
askme = ws.Prompt(PROMPT_YESNO, "PNAB: Delete old documents?", msg)
If askme = 0 Then
Messagebox "Nothing deleted. Nothing restored. Exit", 0, "PNAB"
Exit Sub
End If
For n = 1 To collection.Count
Set doc = collection.GetNthDocument(n)
Call doc.Remove(True)
Next
End If
' Find all Person and Group documents in the Mailfile.
' copy these documents from mailfile to PNAB
formula = "Form = ""Person"" | Form = ""Group"" "
Set collection = maildb.Search( formula, Nothing, 0 )
ndocs = 0
For n = 1 To collection.Count
Set doc = collection.GetNthDocument(n)
doc.FUPPSdn = user
' doc.NameDisplaypref = "1" ' Firstname Lastname
doc.NameDisplayPref = "2" ' Lastname, Firstname
' Contacts which are created by a Web browser have no
' Type in the document. I'm going to set it here...
' The same occurs in Groups, but I cannot set them here because
' WebGroups are created with email address only and NotesGroups
' with the FullName of the Contact
If doc.Form(0) = "Person" And doc.Type(0) = "" Then
doc.Type = "Person"
End If
If doc.Form(0) = "Group" Then
If Not doc.HasItem("Type") Then
Dim f1 As NotesItem
Set f1 = doc.AppendItemValue( "Type" , "Group")
End If
If Not doc.HasItem("GroupType") Then
Dim f2 As NotesItem
Set f2 = doc.AppendItemValue( "GroupType" , "1")
End If
End If
Call doc.Save(True,True)
Call doc.CopyToDatabase(pnab)
ndocs = ndocs + 1
Next
msg = ndocs & " restored to personal address book from mailfile"
Messagebox msg, 0, "PNAB"
End Sub
Depending on whether you prefer names sorted
by first or last names, adjust the line which sets the preference. I want
names sorted by surname, which is how it is set. If you prefer sorting by
first or given name, set NameDisplayPref
to the value 1
. Notice that I
have removed the Synchronize Address Book agent from my mail file in so as to
not use it by mistake. Choose Recreate PNAB People from
the Actions menu to launch the agent. If you already have people in your
personal address book on the workstation (
names.nsf
), the agent will request
permission to delete those. If you answer with No, the
agent terminates and doesn’t otherwise alter anything. Answering yes to the
question lets the agent remove all person (not connection or other documents)
from your
names.nsf
, and it then copies all person and group documents from
your mail file into your personal address book, indicating how many where thus
created This function can be used on each of your
workstations without endangering the addresses in the person documents of the
mail file. Do note that any changes to the names.nsf will of course be
clobberred at the next run. If you want read/write access to the address book
in your mailfile, use iNotes to access it.