I wrote this code for use in a submit button, but it can be modified...the key thing that it does is parse the database ACL looking for users with the specified role. Those with the role are appended to the SendTo field of the uidocument. This is useful in a workflow app, where, for example, electrical submits to test...from electrical submit button, we need to find all with the test role for notification of section completion. By simply changing the "role" argument, the code will work in other similar sections as well...as is necessary...i.e., if test then submits to quality, just pop the code into test submit button and change the role to "quality". This elimates the need to hard code lists of users with @MailSend. From this point, someone annointed as manager of the database can add and remove users from the accompnying mailing lists for the sections simply by adding and removing roles from their listing in the ACL....effectively passing control of all notifications to the ACL...a front end non-designer interface. Also, code is included for field validation, where more fields can obviously be added or removed from the validation tests as desired.
Sub Click(Source As Button) ' This code written by A. Young on 8/15/2001 ' Parses ACL for role which determines who receives mail for this section ' Builds list and sends mail to the specified users 'Code is designed to be completely modular, the only change required being the role that is being used 'Declare Dim workspace As New NotesUIWorkspace Dim ns As New NotesSession Dim ndb As NotesDatabase Dim uidoc As notesuidocument Dim nacl As NotesACL Dim nacle As NotesACLEntry Dim maildoc As NotesDocument Dim rtitem As NotesRichTextItem Dim varACLRoles As Variant Dim intFlag As Integer Dim listTotal As Integer Dim failChecks As Integer Dim this As String Dim this1 As String Dim this2 As String Dim fieldCheck1 As String Dim fieldCheck2 As String Dim message As String 'Initialize Set uidoc = workspace.CurrentDocument Set ndb = ns.CurrentDatabase Set nacl = ndb.ACL Set nacle = nacl.GetFirstEntry fieldCheck1 = uidoc.FieldGetText("<fieldtocheck1") fieldCheck2 = uidoc.FieldGetText("<fieldtocheck2>") listTotal = 0 failChecks = 0 message = "Your form was not submitted for the following reasons:" + Chr(10) + Chr(10) If fieldCheck1 = "" Then failChecks = 1 message = message + "<Your error message here.>" + Chr(10) End If If fieldCheck2 = "" Then failChecks = 1 message = message + "<Your error message here>" + Chr(10) End If If failChecks <> 0 Then Goto Finish End If Do While Not (nacle Is Nothing) Set naclEnter = nacl.GetEntry( nacle.Name ) intFlag = naclEnter.IsRoleEnabled("<RoleNameToCheck>") If intFlag Then uidoc.EditMode = True this = Strright(nacle.Name, "CN=") this1 = Strleft(this,"O=") this2 = Strright(this,"/O=") Call uidoc.FieldAppendText("SendTo", this1 + this2) listTotal = listTotal + 1 End If Set nacle = nacl.GetNextEntry(nacle) Loop If listTotal <> 0 Then Set doc = New NotesDocument(ndb) doc.SendTo = uidoc.FieldGetText("SendTo") doc.Form = "Memo" doc.Subject = "<Notification of subject here>" membody = "<Text intro placed in top of email memo>" + Chr(10) Set rtitem = New NotesRichTextItem(doc, "Body") Set maildoc = uidoc.Document Call rtitem.AppendText(membody) Call rtitem.AppendDocLink(maildoc, "<Text next to link>") Call doc.Send( True, doc.SendTo ) Msgbox "<Successfully submitted message>", 64, "Submit completed." Call uidoc.FieldSetText("SendTo"," ") Call uidoc.FieldSetText("Status", "Submitted") Call uidoc.Save Call uidoc.Close End If If listTotal = 0 Then Msgbox "Submit not accepted. There is no one with the required role in this database.", 16, "This submit has failed." End If If failChecks <> 0 Then Finish: message = message + Chr(10) + "Please make the above changes and press Submit again" Messagebox message, 0+16, "Your Form was NOT submitted." End If End Sub