Multiple Names in SendTo

I am looking at an agent which runs in my Domino environment which no longer seems to be functioning properly.

The agent runs through a list of documents in a view, and if certain criteria are met, sends an email to any recipients listed in a names field in the currently selected document in the view

This seems to be working fine if the names field only contains one name, but is failing when there are multiple names.

A snippet of code from the original agent is below:

Call SendMsg(MonDoc.Notification_Mon,…

where SendMsg is a sub which creates a notesdocument of form “Memo” and puts the 1st variable passed into the SendTo field before sending. MonDoc is the notes document from the view which has the Notification_Mon names field.

I have tried modifying the agent to iterate through the names field building up a string to pass instead of passing the field reference. This is below:

Recip=“”

	RecipField = MonDoc.GetItemValue("Notification_Mon")

	Forall n In RecipField

		Set Names = New NotesName(n)

		If Recip="" Then

			Recip= Names.Abbreviated

		Else

			Recip=Recip & ", " & names.Abbreviated

		End If

	End Forall

And then calling SendMsg with Recip as the first variable. I have also tried changing the names.X to see if that helped but it did not.

When running this agent from the Actions menu, I get the error that it couldn’t find the name in the domino address book.

As a debug I have had it send the emails directly to me, putting in the Recip value into the body of the email, and it always looks fine to me, sending back somethign like “name/domain, name2/domain”

What am I doing wrong?

Subject: Multiple Names in SendTo

Multivalue fields are stored as arrays.

You have provided a single string which if entered via the UI would be translated into an array before storage.

Try this:

Dim i as Integer

If isArray(Recipfield) then

. . For i = LBound(Recipfield) to UBound(Recipfield)

. . . . Set Names = New NotesName(Recipfield(i))

. . . . Recipfield(i) = Names.Abbreviated

. . Next

Else

. . Set Names = New NotesName(Recipfield)

. . Recipfield = Names.Abbreviated

End If

Then send your mail using Recipfield.

Subject: RE: Multiple Names in SendTo

I always use an array when I need to send mail to multiple users.

Subject: Multiple Names in SendTo

Hello,

make the SendTo a multivalue field.

So modify the code like this:

RecipField = MonDoc.GetItemValue(“Notification_Mon”)

Forall n In RecipField

Set Names = New NotesName(n)

if maildoc.HasItem("SendTo") then

	call maildoc.GetFirstItem("SendTo").AppendToTextlist(names.Abbreviated)

else

	maildoc.SendTo = names.Abbreviated	

End If

End Forall

The error ist the comma separated list you use. Domino treats this entry as on value and cannot find this single name containing commas.

If you enter name1, name2 into the sendto feld of the Mail Form, it will be translatet to a multivalue list by the form.

hth

thomas

Subject: RE: Multiple Names in SendTo

Thanks Thomas, that seems to have done the trick. I wasn’t aware the Notes client would be seeing the comma as an entry