Sending a document to multiple recipients using Lotusscript

I'm using Lotusscript to send an email with a doclink to multiple recipients. The list of recipients is a concatenation of several fields....this does not seem to work, though. My code works fine for a single recipient - I'm just not sure how to format the list of multiple recipients. I've tried using different delimiters and using an array, but can't anything to work.

Dim workspace As New NotesUIWorkspace
Dim db As NotesDatabase
Dim newDoc As NotesDocument
Dim rtitem As NotesRichTextItem
Set db = session.CurrentDatabase
Set uidoc = workspace.CurrentDocument
Set newDoc = New NotesDocument( db )
Set rtitem = New NotesRichTextItem( newDoc, "Body" )
Call rtitem.AppendDocLink( uidoc.Document, db.Title)
newDoc.Subject = "My subject"  
newDoc.SendTo = uiDoc.FieldGetText("Recipient1") & ", " & uiDoc.FieldGetText("Recipient2") & ", " & uiDoc.FieldGetText("Recipient3")
newDoc.Send( False )
Who is Participating?
Your LotusScript could combine the values of the three fields.  The simplest code for this is:

Dim recipients As Variant
Const recipientsComboFormula = "@Trim(Recipient1 : Recipient2 : Recipient3)"
recipients = Evaluate(recipientsComboFormula, uiDoc.Document)
It needs to be an array.  Assuming that recipient1, recipient2, and recipient3 each contains a single person, this would work:

Dim recipients(1 to 3) as string
recipients(1) = uiDoc.FieldGetText("Recipient1")
recipients(2) = uiDoc.FieldGetText("Recipient2")
recipients(3) = uiDoc.FieldGetText("Recipient3")
newDoc.replaceItemValue "SendTo", recipients
mrt1Author Commented:
OK, thanks. What if each of the fields (recipient1, recipient2, etc) could contain multiple names?
Would the same method still work?
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

Sjef BosmanGroupware ConsultantCommented:
Do you have multiple recipient fields? What if you use only one multi-value recipients field? You won't need the Dim recipients, just say
    newDoc.SendTo= uiDoc.Document.Recipients
mrt1Author Commented:
Afraid I have multiple fields.....I can't use a single field
Sjef BosmanGroupware ConsultantCommented:
Next option: can you add (another) multiple-value field, e.g. with the name Recipients, type Computed, with the formula:
and use in LS:
    newDoc.SendTo= uiDoc.Document.Recipients
Sjef BosmanGroupware ConsultantCommented:
Obvious mistake:
1. Create a dynamic array to hold all recipients
2. For each field value, check if it has more than one value. then put all values to the dynamic array one by one
Sjef BosmanGroupware ConsultantCommented:
Well, that's what Qwaletee's Evaluate will do for you, all-in-one solution.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.