Skip to main content
4-Participant
June 16, 2022
Solved

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

  • June 16, 2022
  • 1 reply
  • 2226 views

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."

 

 

 

 

Best answer by nmutter

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.

1 reply

24-Ruby III
June 17, 2022

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

4-Participant
June 17, 2022
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.
16-Pearl
June 22, 2022

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