[resolved] tSendMail dynamic message

Highlighted
One Star

[resolved] tSendMail dynamic message

Hello!
i want tSendMail with a dynamic message.
I have a text in a file, and i want send it with tSendMail.
I try with tFileInputDelimited, but it send an email for each lines of my file, but i want only one email with all lines of my file.
Someone know how to do?
(sorry maybe my english is not very goodSmiley Happy )
Thx

Accepted Solutions
Community Manager

Re: [resolved] tSendMail dynamic message

Hi
Use a tFileInputFullRow to read the file line by line, concatenate all lines with separator "\n" and store the result to a context variable on tJava, the job design is read as below:
tFileInputFullRow--main--tJavaRow
|
onsubjobok
|
tSendMail
Open the Context view and define a variable, name it as "message" for example, and set its default values as "".
on tJavaRow:
if(context.message.equals("")){
context.message=input_row.line;
}else{
context.message=context.message+"\n"+input_row.line;
}
On tSendMail, set the Message field with context variable, for example:
"The file content is: "+context.message
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business

All Replies
Community Manager

Re: [resolved] tSendMail dynamic message

Hi
Use a tFileInputFullRow to read the file line by line, concatenate all lines with separator "\n" and store the result to a context variable on tJava, the job design is read as below:
tFileInputFullRow--main--tJavaRow
|
onsubjobok
|
tSendMail
Open the Context view and define a variable, name it as "message" for example, and set its default values as "".
on tJavaRow:
if(context.message.equals("")){
context.message=input_row.line;
}else{
context.message=context.message+"\n"+input_row.line;
}
On tSendMail, set the Message field with context variable, for example:
"The file content is: "+context.message
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] tSendMail dynamic message

Thank you,
i just test it works good Smiley Happy

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’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

Agile Data lakes & Analytics

Accelerate your data lake projects with an agile approach

Watch