How can I using lotus script ensure that a person only gets one email.

We've developed application called e-Notice that function as notice board. Previously when mailing using group names with the @mailsend (formula), there are no problem as recipient only receive one mail even though they register with more that 1 group.
However when I develop one module using lotus script, the mail.send function cannot perform such auto filtering. As a result recipient who be in more than 1 group will receive more than 1 notification email.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

you need to use ArrayUnique by expanding groups or create one group with unique id's.
Let's see if other experts has better suggestions.
You can resolve groups to users and then use unique list as recipients.
That would work fine while users are connected to the server, but when local group is not going to be resolved (you need NAB access to do that).
Function GetAllUsersInGroup( groupname As String, Server As String, maxdepth As Integer ) As Variant
	This function gets all the users in any group, including nested subgroups.
	This is a RECURSIVE function, so be careful when modifying it.
	MAXDEPTH is used to regulate how far down in group levels it can go.
	If checking ACL groups, 6 is the limit, for mail groups its 20 -- but this can change with Domino versions in the future.

	This sample code is distributed freely with only one obligation. You must distribute this code as a whole, including these comments, if you distribute it or re-use it at all. 
	For help, please contact
	Andrew Pollack
	Northern Collaborative Technologies

      ' use static variables so that you can avoid repeatedly
      ' getting a handle to the same resources.
      Static nab As notesdatabase
      Static nabview As notesview
      Static groupview As notesview
      Static foundlist List As String
      Static checkedgroups List As String
      Static depth As Integer

      ' this is the list containing the results to return
      Dim returnlist List As String

      ' just a stray string variable to be used
      Dim tempstring As String

      ' set this to return the empty list, in case we have to exit due to error
      getallusersingroup = returnlist

      ' since depth is a static variable, each recursive call to this
      ' function will increase its value.  We can also decrease its
      ' value so we know when we're back to the initial call.
      If depth => maxdepth Then Exit Function  ' don’t look deeper then n nested groups
      depth = depth + 1

      ' check to see if we haven't already connected to the nab & views
      ' if not, connect now.
      If nab Is Nothing Then Set nab = New notesdatabase(server,"NAMES.NSF")
      If nab Is Nothing Then Exit Function
      If nabview Is Nothing Then Set nabview = nab.getview("($ServerAccess)")
      If groupview Is Nothing Then Set groupview = nab.getview("($VIMGroups)")
      If groupview Is Nothing Then Exit Function
      If nabview Is Nothing Then Exit Function

      ' declarations
      Dim collection As notesdocumentcollection
      Dim doc, checkdoc As notesdocument
      Dim v As Variant
      Dim count As Integer
      Dim usercount As Integer
      Dim user As notesname

      ' Now we get to the meat of the function
      Set doc = groupview.getdocumentbykey(groupname, True) ' first, find the group

      If doc Is Nothing Then Exit Function ' there is no group

      Forall member In doc.members ' for each entry in the the group
            tempstring = Ucase$(member)
            ' *******************************************************
            ' make sure we haven't already checked this entry
            If Not Iselement(returnlist(tempstring)) Then
                  If Not Iselement(foundlist(tempstring)) Then
                        If Not Iselement(checkedgroups(tempstring)) Then
            ' *******************************************************
                              Set checkdoc = groupview.getdocumentbykey(tempstring, True)
                              If checkdoc Is Nothing Then
                              ' treat as a user, add them to the return and found lists
                                    foundlist(tempstring) = "1"
                                    returnlist(tempstring) = "1"
		      		    ' this is a new group to check
                              ' so we recursively call this very function with the new groupname
                                    checkedgroups(tempstring) = "1"
                                    v = GetAllUsersInGroup( tempstring, server, maxdepth )
                                    Forall newmember In v
                                          ' add the results from the recursive call to the return lists
                                          returnlist(Listtag(newmember)) = "1"
                                          foundlist(Listtag(newmember)) = "1"
                                    End Forall
                              End If
                        End If
                  End If
            End If
      End Forall

      ' whew, now just return the list of all we found, plus all those found by
      ' any recursive calls we made, and the calls they made, and the calls they made, ...
      getallusersingroup = returnlist
      depth = depth -1

      If depth = 0 Then
	' this exit will be the last recursion, so delete the static list so we can run again if we need!
            Erase foundlist
            Erase checkedgroups
      End If

End Function

Function Unique(vIn As Variant) As Variant
	Dim lsTemp List As String     'Create the list
	Dim astemp() As String       'A place to store the compacted array
	Dim iCount As Integer         'Count how many uniques we find

	'Make sure they sent us an array of strings
	If Not Isarray(vIn) Then
		Msgbox "Unique requires an array as input"
		UniqueA = vIn
		Exit Function
	Elseif Typename( vIn(0) ) <> "STRING" Then
		Msgbox "Unique requires an array of strings as input. vIn(0) is a " _
		+ Typename( vIn(0) )
		UniqueA = vIn
		Exit Function
	End If

	Forall s In vIn
		'If the entry isn't in the list...
		If Not Iselement( lsTemp(s) ) Then
			'Add it to the list
			'Note that we don't care what's in the list; we just want the list tag
			lsTemp(s) = ""
			iCount = iCount + 1
		End If
	End Forall

	'Note that there's no "preserve" keyword here so this is relatively quick
	Redim asTemp(iCount-1)

	iCount = 0
	'Copy all the unique elements into the temp array
	Forall v In lsTemp
		asTemp(iCount) = Listtag(v)
		iCount = iCount + 1
	End Forall

	'Return the temp array
	UniqueA = asTemp
End Function

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Sjef BosmanGroupware ConsultantCommented:
Do you send ONE mail, or do you send the same mail multiple times, to different recipients?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.