• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2668
  • Last Modified:

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 )
0
mrt1
Asked:
mrt1
  • 4
  • 2
  • 2
  • +1
1 Solution
 
qwaleteeCommented:
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
0
 
mrt1Author Commented:
OK, thanks. What if each of the fields (recipient1, recipient2, etc) could contain multiple names?
Would the same method still work?
0
 
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
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
mrt1Author Commented:
Afraid I have multiple fields.....I can't use a single field
0
 
Sjef BosmanGroupware ConsultantCommented:
Next option: can you add (another) multiple-value field, e.g. with the name Recipients, type Computed, with the formula:
    @Unique(Recipients:Recipients:Recipients3)
and use in LS:
    newDoc.SendTo= uiDoc.Document.Recipients
0
 
Sjef BosmanGroupware ConsultantCommented:
Obvious mistake:
    @Unique(Recipient1:Recipient2:Recipients3)
0
 
qwaleteeCommented:
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)
newDoc.Send(False,recipients)
0
 
yangshuhuaCommented:
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
0
 
Sjef BosmanGroupware ConsultantCommented:
Well, that's what Qwaletee's Evaluate will do for you, all-in-one solution.
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

  • 4
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now