Sub Click(Source As Button) Dim session As New NotesSession Dim db_current As NotesDatabase Dim db_names As New NotesDatabase ("","") Dim ws As New NotesUIWorkspace Dim uidoc As NotesUIDocument Dim doc As NotesDocument Dim db_toFind As NotesDatabase Dim i As Integer Dim file_path As String Dim server_name As String Dim replicaID As String Dim field_number As String Dim flag As Integer Dim msg_error As String Dim view_setup As NotesView Dim doc_setup As NotesDocument Dim database_name As String Dim found As Integer Dim nb_setup As Integer Dim db_names_tab() As NotesDatabase Dim view_names_users_tab() As NotesView Dim NabTab() As NAB Dim doc_NAB As NotesDocument Dim item_recipients_address As NotesItem Dim address As String On Error GoTo MANAGE_ERROR Set db_current = session.CurrentDatabase Set uidoc = ws.CurrentDocument Set doc = uidoc.Document ' ### Build a table of all available NAB defined in Setup documents Set view_setup = db_current.GetView("DskMgrSetup") If view_setup Is Nothing Then msg_error = |"DskMgrSetup" view is nothing| GoTo MANAGE_ERROR End If nb_setup = 0 Set doc_setup = view_setup.GetFirstDocument While Not (doc_setup Is Nothing) If doc_setup.SETUP_NABDatabase(0) <> "" And doc_setup.SETUP_NABServer(0) <> "" Then nb_setup = nb_setup + 1 Set doc_setup = view_setup.GetNextDocument(doc_setup) Wend If nb_setup = 0 And db_current.Server = "" Then msg_error = |No setup document and the current database is on local| GoTo MANAGE_ERROR End If ReDim NabTab(1 To nb_setup + 1) nb_setup = 0 Set doc_setup = view_setup.GetFirstDocument While Not (doc_setup Is Nothing) If doc_setup.SETUP_NABDatabase(0) <> "" And doc_setup.SETUP_NABServer(0) <> "" Then server_name = doc_setup.SETUP_NABServer(0) database_name = doc_setup.SETUP_NABDatabase(0) If nb_setup = 0 Then nb_setup = nb_setup + 1 NabTab(nb_setup).server_name = server_name NabTab(nb_setup).database_name = database_name Else found = 0 For i=1 To nb_setup If UCase$(NabTab(i).server_name) = UCase$(server_name) And UCase$(NabTab(i).database_name) = UCase$(database_name) Then found = 1 Exit For End If Next If found = 0 Then nb_setup = nb_setup + 1 NabTab(nb_setup).server_name = server_name NabTab(nb_setup).database_name = database_name End If End If End If Set doc_setup = view_setup.GetNextDocument(doc_setup) Wend ' ## Add the NAB of the current DskMgr server If db_current.Server <> "" Then server_name = db_current.Server database_name = "names.nsf" found = 0 For i=1 To nb_setup If UCase$(NabTab(i).server_name) = UCase$(db_current.server) And UCase$(NabTab(i).database_name) = UCase$("names.nsf") Then found = 1 Exit For End If Next If found = 0 Then nb_setup = nb_setup + 1 NabTab(nb_setup).server_name = server_name NabTab(nb_setup).database_name = database_name End If End If ' # Nothing to do If nb_setup = 0 Then msg_error = |No setup document| GoTo MANAGE_ERROR End If ' ### Open all the NAB databases, the $Users views and the $Groups views, if one failed, exit ReDim db_names_tab(1 To nb_setup) ReDim view_names_users_tab(1 To nb_setup) For i = 1 To nb_setup Set db_names_tab(i) = New NotesDatabase(NabTab(i).server_name,NabTab(i).database_name) If (db_names_tab(i) Is Nothing) Then msg_error = "The database '" + NabTab(i).server_name + "!!" + NabTab(i).database_name + "' doesn't exist." GoTo MANAGE_ERROR End If If Not (db_names_tab(i).isopen) Then msg_error = "Impossible to open NAB database '" + NabTab(i).server_name + "!!" + NabTab(i).database_name + "'" GoTo MANAGE_ERROR End If Set view_names_users_tab(i) = db_names_tab(i).GetView("($Users)") If view_names_users_tab(i) Is Nothing Then msg_error = "Impossible to open the ($Users) view in the NAB database " + NabTab(i).database_name + " on server " + NabTab(i).server_name GoTo MANAGE_ERROR End If Next ' # Empty the destination field If (doc.HasItem("HOOK_RUS_List")) Then doc.HOOK_RUS_List = "" End If ' ## Searching Reicpients Names in the NABs ForAll recipients_name In doc.HOOK_RUS_List_1 ' ## Searching in all the $Users view in the available NABs found = 0 For i = 1 To nb_setup ' # Searching name the $Users view Set doc_NAB = view_names_users_tab(i).GetDocumentByKey(CStr(recipients_name),True) If Not (doc_NAB Is Nothing) Then found = 1 Exit For End If Next ' ## Set the recipients address field Set item_recipients_address = doc.GetFirstItem("HOOK_RUS_List") If item_recipients_address Is Nothing Then Set item_recipients_address = doc.ReplaceItemValue("HOOK_RUS_List", CStr(recipients_name)) Else Call item_recipients_address.AppendToTextList(CStr(recipients_name)) End If ' ## Name was found in the NABs If (found = 1) Then ' ## Get the NAB fields Select Case doc_NAB.Type(0) Case "Person" Call item_recipients_address.AppendToTextList(doc_NAB.GetItemValue("FullName")) Call item_recipients_address.AppendToTextList(doc_NAB.GetItemValue("InternetAddress")) Call item_recipients_address.AppendToTextList(doc_NAB.GetItemValue("ShortName")) Case "Database" Call item_recipients_address.AppendToTextList(doc_NAB.GetItemValue("FullName")) Call item_recipients_address.AppendToTextList(doc_NAB.GetItemValue("InternetAddress")) Case "Group" Call item_recipients_address.AppendToTextList(doc_NAB.GetItemValue("ListName")) Call item_recipients_address.AppendToTextList(doc_NAB.GetItemValue("InternetAddress")) End Select End If End ForAll EXIT_SUB: Exit Sub MANAGE_ERROR : If (msg_error="") Then msg_error = "("+Cstr(Erl)+") " + Error MsgBox msg_error,48,db_current.title GoTo EXIT_SUB End Sub