Desmond Sim
Desmond Sim

Reputation: 211

Fail to send multiuser email

Case: i would like to Blind Copy TO multiuser [send mail]

GMHRM

method 1: using vector [Fail] with error message say is null

var maildoc:NotesDocument = database.createDocument();
maildoc.replaceItemValue("Form", "Memo");
maildoc.replaceItemValue("Subject", "STATUS OF APPLICATION FOR REQUEST AN EMAIL");
session.setConvertMime(false);
var z:java.util.Vector = new java.util.Vector();

var vw:NotesView = database.getView("(Notifier Setting)");
var doc:NotesDocument = vw.getFirstDocument();
if (doc != null) {
    z.addElement(doc.getItemValue("HRM"));
    z.addElement(doc.getItemValue("GM"));
}
maildoc.replaceItemValue("BlindCopyTo",z)

method 2: using array [Fail] with error message replaceitemvalue cannot used array

var z=[];
var vw:NotesView = database.getView("(Notifier Setting)");
var doc:NotesDocument = vw.getFirstDocument();
if (doc != null) {
    z.push(doc.getItemValue("HRM"));
    z.push(doc.getItemValue("GM"));
}
maildoc.replaceItemValue("BlindCopyTo",z)

method 3:Using string [no person in blindcopy list]

maildoc.replaceItemValue("BlindCopyTo",doc.getItemValue("HRM")+","+doc.getItemValue("GM"))

May i know which way is correct way?

Upvotes: 0

Views: 69

Answers (1)

xpages-noob
xpages-noob

Reputation: 1579

The function NotesDocument.getItemValue() returns a (java.util.)Vector, so if you use addElement or push on z (as in methods 1 and 2), it just adds the whole vector instead of its children.

Your code should work if you use method 1 and replace

z.addElement(doc.getItemValue("HRM"));
z.addElement(doc.getItemValue("GM"));

with

z.addAll(doc.getItemValue("HRM"));
z.addAll(doc.getItemValue("GM"));

PS: Mark Leusink has written a nice SSJS class for mail sending which is available in OpenNTF XSnippets.

Upvotes: 3

Related Questions