Using LotusScript, I need to take values from 3 separate name fields (each with a single value), and combine these into a single multi-value SendTo field.
…but it seems to choke on the commas. So (based on another post here) I tried…
SendTo(0) = doc.FirstName(0)
SendTo(1) = doc.SecondName(0)
SentTo(2) = doc.ThirdName(0)
But this isn’t working either, and I don’t understand why.
On one hand, I feel like I’m missing something obvious. But on the other hand, our previous Notes developer “solved” this by putting FirstName in SendTo, SecondName in CopyTo, and ThirdName in BlindCopyTo. Beyond 3 names, we were told we’re out of luck.
What you should do is use the NotesItem class to add values to your SendTo field.
Dim item As NotesItem
set item = NotesDocument.ReplaceItemValue(“SendTo”, “Name 1 goes here”)
Call item.AppendToTextList(“Name 2 goes here”)
Call item.AppendToTextList(“Name 3 goes here”) 'Repeat as necessary
Of course, it you don’t know in advance how many names you need to add, you might want to loop through an array of values or something that makes sence in your context.
Subject: RE: SendTo Multi-Value Names in LotusScript
The statements:
SendTo(0) = doc.FirstName(0)
SendTo(1) = doc.SecondName(0)
SentTo(2) = doc.ThirdName(0)
will work just fine, in the proper context. The proper context is:
SendTo is a three-element array of strings (e.g. Dim SendTo(0 to 2) As String ). Redim will also work, in case you don’t know the number of recipients in advance.
You do something with SendTo afterwards that tells Notes to use it as the address when sending the email, since SendTo as a variable name has no special meaning. E.g. Call doc.Send(False, SendTo)
A comma-delimited or other delimited list will not work, because when you send mail in any of the languages, Notes is expecting you to supply a list/array with one address in each element.
Another way is to declare SendTo as variant and assign it with Evaluate, e.g.:
Which doesn’t execute as fast, probably, but has the advantage of simplicity, especially if some fields are optional and you’re like to not try to send mail to “” (it is unlikely to be delivered successfully).
Subject: RE: SendTo Multi-Value Names in LotusScript
SendTo is already a multi-value Names field. Not being very adept in LotusScript, I assumed that “multi-value” makes it an array (?) and that I would be okay as long as I assigned values that could be resolved as Names. But in any case…
I used your suggestion of Evaluate(…) and that seems to work fine! I tried a variation on this eariler, but must have missed something.
Subject: RE: SendTo Multi-Value Names in LotusScript
One more way which you might find useful - take a look the AppendToTextList method in the designer help.
BTW, an advantage of the Evaluate method you are using is that you can include @Unique in the formula to handle the possibility of the same name being listed more than once.