Skip to main content
4-Participant
Solved

Retrieve multiple email addresses from data table and insert as input into email service

I have a service where I retrieve one to many email addresses from my data table based on certain inputs. How do insert these into the send message service? It currently gives me the following error,

 

"javascript service. Message ::Invalid or malformed email address entered."

 

 

 

 

nmutterAnswer
17-Peridot

I'm not so clear what you want to do as the code you provided seems to be missing some comments and brackets.

 

But creating a string like "email1;email2;email3;" for the SendMessage service you can just do

var tableLength = result.rows.length;
var emailReceivers = ""; // empty mail string
for (var x = 0; x < tableLength; x++) {
 var row = result.rows[x];
 emailReceivers += row.Email + ";"; // append "email;" to receivers
}

if (emailReceivers.length > 0)
 emailReceivers = emailReceivers.slice(0, -1); // remove last ;

Hope this helps.

7 replies

24-Ruby IV

Article - "How to send an email to multiple recipients via ThingWorx Mail Extension": https://www.ptc.com/en/support/article/cs310001 

Translate
4-Participant
Thank you, but I need help on the for loop to go through my results from the data table and put the semicolon in between each result.
Translate
17-Peridot

can you share some code so we can help with it?

Translate