0

Names is not getting resolved while using HTML mail in xpages. Is it a problem with the snippet i took from xsnippet or problem with mime itself.

import ss_html_mail;

var mail = new HTMLMail();
var res:java.util.Vector = new java.util.Vector();
res.add("Soundararajan, Thirun");
res.add("Arumugam, Barath");
res.add("Selvam, Abirami")
res.add("Panneerselvam, Saravanan")
mail.setTo(res);
mail.setSubject("HTML Mail");
mail.addHTML("HTML Mail");
mail.send();

However if replace those names with email address or use default SSJS send function it is working. Default send() function resolves the names to email properly

res.add("Soundararajan.Thirun@gmail.com");
res.add("Arumugam.Barath@gmail.com");
res.add("Selvam.Abirami@gmail.com")
res.add("Panneerselvam.Saravanan@gmail.com")

or

var doc = database.createDocument();
var res:java.util.Vector = new java.util.Vector();
res.add("Soundararajan, Thirun");
res.add("Arumugam, Barath");
res.add("Selvam, Abirami")
res.add("Panneerselvam, Saravanan")
doc.replaceItemValue("Form", "Memo");
doc.replaceItemValue("Subject", "An email");
doc.replaceItemValue("SendTo", res);
doc.send();
Saravanan
  • 1,237
  • 2
  • 18
  • 25
  • 1
    It would help us to troubleshoot if you could include (or at least link to) the snippet you refer to, since there's no way to tell from what you've listed above what `HTMLMail` actually does. Most likely, however, it's treating the comma as a multi-value delimiter, so `"Selvam, Abirami"` does not work, but `"Abirami Selvam"` probably would. – Tim Tripcony Feb 02 '14 at 19:42
  • @Tim, I believe it's http://openntf.org/XSnippets.nsf/snippet.xsp?id=create-html-mails-in-ssjs-using-mime. – Egor Margineanu Feb 03 '14 at 00:52
  • Yes. It is the same Snippet. As Tim said, i think it is problem with comma in the names. Is it possible to allow comma in setHeaderVal and use semi colon as delimiter? – Saravanan Feb 03 '14 at 06:56
  • I agree with Tim: the comma in the names is causing the problem. If you check line 155 of my snippet, a comma is used as a delimiter for multiple values in the To header (as well as the the CC and BCC headers). I wouldn't recommend using any other character in those headers as a multi-value separator. – Mark Leusink Feb 03 '14 at 08:38

1 Answers1

0

I use this xsnippet all the time and the problem in your code is that you are using an vector to add the names in. Try to add the names in a Javascript array instead. Like this

import ss_html_mail;

var mail = new HTMLMail();
var res=[]
res.push("Soundararajan, Thirun");
res.push("Arumugam, Barath");
res.push("Selvam, Abirami")
res.push("Panneerselvam, Saravanan")
mail.setTo(res);
mail.setSubject("HTML Mail");
mail.addHTML("HTML Mail");
mail.send();
Fredrik Norling
  • 3,461
  • 17
  • 21