Compose memo, populate SendTo w/database column values

Have you ever wanted to send an e-mail to a list of people in a database field value?

Have you ever wanted to send an e-mail to a list of people in a database field value? Say all Project Managers? This agent will retrieve a column of Name values from any view in the current database, then optionally validate those names against the Public NAB. The agent will compose a memo in the user's mail and populate the EnterSendto (R5) or SendTo (R4) field with the validated entries.

'---(Declarations)--- Private NABdb As notesdatabase Private NABview As notesview Private NABdoc As notesdocument Dim recipient List As Variant Dim memo As NotesUIDocument Dim SendToField As NotesItem Sub Initialize '// change 'ActiveFocusTeam' to desired view as '// well as the column value following this will return a '// variant containing a unique list of all members in '// the selected column evaluationString = {@Unique(@DbColumn("":"nocache";"";"ActiveFocusTeam";1))} resultsList = Evaluate(evaluationString) '// validate all entries in the returned list using '// CheckValidName (
  ) returning True or False '// NOTE: If you are certain the list returned contains '// all valid names, change the following line to False ValidateEntries = True If ValidateEntries Then ValidateWithNAB resultsList '// open mail document and populate SendTo Field Dim db As New NotesDatabase( "", "" ) Dim ws As New NotesUIWorkspace Call db.OpenMail Set memo = ws.ComposeDocument(db.Server, db.filepath, "Memo") '// Populate EnterSendTo field with entries (SendTo) Select Case ValidateEntries Case True: Set SendToField = memo.document.GetFirstItem("EnterSendTo") ' R5 Client If SendToField Is Nothing Then Set SendToField = memo.document.GetFirstItem("SendTo") 'R4 Client End If Forall n In recipient Call SendToField.AppendToTextList(n) End Forall Case Else: memo.document.EnterSendTo = resultsList memo.document.SendTo = resultsList End Select memo.AutoReload = True memo.document.subject = "Memo to All Focus Team Members" Call memo.refresh End Sub Private Function CheckValidName(checkname As String) As Variant If NABdb Is Nothing Then Dim s As New NotesSession Set NABdb = s.getdatabase(s.currentdatabase.server,"names.nsf") Set NABview = NABdb.getview("($VIMPeople)") End If Dim pmName As New NotesName( checkname ) 'set the NABdoc value Set NABdoc = NABview.getdocumentbykey(pmName.Abbreviated, True) 'if NABdoc is nothing then no match was found. If NABdoc Is Nothing Then CheckValidName = False Else CheckValidName = True End Function Sub ValidateWithNAB (oListing As Variant) c=0 Forall n In oListing OKtoAdd = CheckValidName ( Cstr(n) ) '// if a valid match was found, adds to the recipient list If OKtoAdd Then recipient(c) = Cstr(n) c=c+1 End If End Forall End Sub


Dig Deeper on Domino Resources - Part 3

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.




  • iSeries tutorials's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...