I attach the code below as text, but also as a Notes DB to allow you to download and test the code
text....
Insert the following two lines in Declarations section
Dim PeopleList() As String
Dim PeopleCount As Integer
This following is the code for a HotSpot button (as an example of where the code can reside)
Sub Click(Source As Button)
'
' This Code creates a list of all email groups and their associated members. It also
' does a lookup to confirm the group members are valid Notes users
'
' To report this information, it requires one field on the form
' named "Body" which is RichText and Editable
'
' There is one Function "IsValidPerson" and two Global Declarations
Dim workspace As New NotesUIWorkspace
Dim session As New NotesSession
Dim db As New NotesDatabase( "", "" )
Dim GroupView As NotesView
Dim PersonView As NotesView
Dim GroupDoc As NotesDocument
Dim PersonDoc As NotesDocument
Dim uidoc As NotesUIDocument
Dim rtitem As Variant
Dim txtServer As String
Dim txtFilename As String
Dim Nam As NotesName
' Get the Server of the Address Book
Dim s As New NotesSession
Forall book In s.AddressBooks
book.open "", ""
If Book.Server<>"" Then
tmpServer=Book.Server
tmpFileName=Book.FileName
Exit Forall
End If
End Forall
' Prompt user to confirm server name and filename
txtServer = workspace.Prompt (PROMPT_OKCANCELEDIT, "Server Name", "Server to check.", tmpServer)
If Isempty (txtServer) Then
Exit Sub
End If
txtFilename = workspace.Prompt (PROMPT_OKCANCELEDIT, "Address Book", "Filename on "+txtServer+"?", tmpFilename)
If Isempty (txtFilename) Then
Exit Sub
End If
' Attempt to Open the server address book
If Not db.Open(txtServer, txtFilename ) Then
Msgbox "Failed to Open the Address Book",16,"Warning"
Exit Sub
End If
' Get List of People
PeopleCount=0
Set PersonView=db.GetView("People")
Set PersonDoc=PersonView.GetFirstDocument
While Not PersonDoc Is Nothing
PeopleCount=PeopleCount+1
Redim Preserve PeopleList(PeopleCount)
PeopleList(PeopleCount)=PersonDoc.FullName(0)
Set PersonDoc=PersonView.GetNextDocument(PersonDoc)
Wend
Set uidoc = workspace.CurrentDocument
Call uidoc.FieldAppendText( "Body", "Group Report - Members List. "+Str(Now))
Call uidoc.FieldAppendText( "Body", Chr(10))
Call uidoc.FieldAppendText( "Body", Chr(10))
' Work Through Groups
Set GroupView=db.GetView("Groups")
Set GroupDoc=GroupView.GetFirstDocument
While Not GroupDoc Is Nothing
' Get Group Type
Select Case GroupDoc.GroupType(0)
Case "0" : tmpGroupType="[Multipurpose]"
Case "1" : tmpGroupType="[Mail Only]"
Case "2": tmpGroupType="[Access Control List Only]"
Case "3" : tmpGroupType="[Deny List Only]"
Case "4" : tmpGroupType="[Servers Only]"
End Select
Call uidoc.FieldAppendText( "Body", GroupDoc.ListName(0))
Call uidoc.FieldAppendText( "Body", Chr(10))
Call uidoc.FieldAppendText( "Body", tmpGroupType)
Call uidoc.FieldAppendText( "Body", Chr(10))
If GroupDoc.ListDescription(0) <> "" Then
Call uidoc.FieldAppendText( "Body", GroupDoc.ListDescription(0))
Call uidoc.FieldAppendText( "Body", Chr(10))
End If
Forall GroupMember In GroupDoc.Members
' Convert Name to Abbreviated format
Set Nam=session.CreateName(GroupMember)
tmpName=Nam.Abbreviated
If Not IsValidPerson(GroupMember) Then
Call uidoc.FieldAppendText( "Body", Chr(9)+tmpName+" - NOT A VALID USER")
Call uidoc.FieldAppendText( "Body", Chr(10))
Else
Call uidoc.FieldAppendText( "Body", Chr(9)+tmpName)
Call uidoc.FieldAppendText( "Body", Chr(10))
End If
End Forall
Call uidoc.FieldAppendText( "Body", Chr(10))
Call uidoc.FieldAppendText( "Body", Chr(10))
Set GroupDoc=GroupView.GetNextDocument(GroupDoc)
Wend
End Sub
Function IsValidPerson(tmpPerson)
Forall People In PeopleList
If People=tmpPerson Then IsValidPerson=True
End Forall
End Function