Solved

Sending a document to multiple recipients using Lotusscript

Posted on 2004-10-26
2,306 Views
Last Modified: 2013-12-18
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
Question by:mrt1
    9 Comments
     
    LVL 31

    Expert Comment

    by:qwaletee
    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
     
    LVL 2

    Author Comment

    by:mrt1
    OK, thanks. What if each of the fields (recipient1, recipient2, etc) could contain multiple names?
    Would the same method still work?
    0
     
    LVL 46

    Expert Comment

    by:Sjef Bosman
    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
     
    LVL 2

    Author Comment

    by:mrt1
    Afraid I have multiple fields.....I can't use a single field
    0
     
    LVL 46

    Expert Comment

    by:Sjef Bosman
    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
     
    LVL 46

    Expert Comment

    by:Sjef Bosman
    Obvious mistake:
        @Unique(Recipient1:Recipient2:Recipients3)
    0
     
    LVL 31

    Accepted Solution

    by:
    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
     
    LVL 1

    Expert Comment

    by:yangshuhua
    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
     
    LVL 46

    Expert Comment

    by:Sjef Bosman
    Well, that's what Qwaletee's Evaluate will do for you, all-in-one solution.
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: From Zero to Hero with Nodejs & MongoDB

    Interested in Node.js, but don't know where to start or how to learn it properly? Confused about how the MEAN stack pieces of MongoDB, Expressjs, Angularjs, and Nodejs fit together? Or how it's even possible to run JavaScript outside of the browser?

    For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
    Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
    With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
    This video is in connection to the article "The case of a missing mobile phone (https://www.experts-exchange.com/articles/28474/The-Case-of-a-Missing-Mobile-Phone.html)". It will help one to understand clearly the steps to track a lost android phone.

    933 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now