tSendMail to multiple recipients get from table

Highlighted
Six Stars

tSendMail to multiple recipients get from table

Hi,

 

I have a job design which works good for single email, but now i have a table for emails and need to get those emails and send report to that list. This table don't have directly link with the report tMap_1. Like this is separate source and not link with report data. Below is job design, Please advise which component i should use to complete this. I am using MySQL Database.

Screenshot_1.jpg

 

 

 

Tags (1)

Accepted Solutions
Fifteen Stars TRF
Fifteen Stars

Re: tSendMail to multiple recipients get from table

You want to send 1 email to a list of persons issued from your DB, right?

So you just have to build the lsit in your tJavaRow using a global variable:

globalMap.put("emailList", ((String)globalMap.getOrDefault("emailList", "")) + "," + input_row.email);

Then in your tSendMail you just have to get the content of the list but the 1rst character to populate the "To" field:

((String)globalMap.get("emailList")).substring(1)

In case of, it could be a good idea to add a tJava (don't change anything inside) before tSendMail, both connected by an "If" trigger with the following condition:

((String)globalMap.get("emailList")) != null

This is to avoid to call tSendMail when the list is empty.


TRF

All Replies
Fifteen Stars TRF
Fifteen Stars

Re: tSendMail to multiple recipients get from table

You want to send 1 email to a list of persons issued from your DB, right?

So you just have to build the lsit in your tJavaRow using a global variable:

globalMap.put("emailList", ((String)globalMap.getOrDefault("emailList", "")) + "," + input_row.email);

Then in your tSendMail you just have to get the content of the list but the 1rst character to populate the "To" field:

((String)globalMap.get("emailList")).substring(1)

In case of, it could be a good idea to add a tJava (don't change anything inside) before tSendMail, both connected by an "If" trigger with the following condition:

((String)globalMap.get("emailList")) != null

This is to avoid to call tSendMail when the list is empty.


TRF
Six Stars

Re: tSendMail to multiple recipients get from table

Thank You, it worked fine.

What’s New for Talend Spring ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Downloads and Trials

Test drive Talend's enterprise products.

Downloads