One Star

Sending Email to Dynamic Address(context Variable)

In my job, I want to send Email to some email addresses which I want to read them from a file.
I have a tFileInputDelimited component with key;value Schema. As a key in every row there is this string: "Email" ,and as value there is an email address. After this component I put a tContextLoad Component. tFileInputDelimited is connected to this component with a main row. As we know, tFileInputDelimited component will repeat next components in its following chain, equals to its rows number.
Then, all of addresses will be loaded in context variable (Here the name of this variable is Email ). But I want each time, tSendMail component, send an email to this address. I put (String)((String)context.getProperty("Email")) in text box of TO field of tSendMail. I connect the tFileInputDelimited with an Iterate row to tSendMail.
What happen::
If tFileInputDelimited has 12 rows, only 11 rows will be sent to addresses. The last address will loose. Because in first time, before Loading the value of Email, tSendMail will be run. Then the first email will be sent to default value of Context Variable (Email), and the last loaded value will not be used by tSendMail.

What can I do?
Do you think there is another or better design of components for this job?
Community Manager

Re: Sending Email to Dynamic Address(context Variable)

Do you think there is another or better design of components for this job?

Using the iterate link to get value of each row.(See the screenshot)
Best regards
Talend | Data Agility for Modern Business
One Star

Re: Sending Email to Dynamic Address(context Variable)

I put an "iteration" field in my file which includes Email Addresses with using a tJavaRow and This Varible: "nb_line_tJavaRow_3" for the vale of this new filed (its start is from zero).
Then with a Context varibale, each time I can read the favorite row of file and send email to Address of that row.
Then in another job I put a tFor component for iterate the first job. And I set the Iteration variable of first job with the number of Iteration (tFor_1_CURRENT_ITERATION). I set the number of iteration in tFor with "tFileRowCount_1_COUNT" which is a field of tFileRowCount which its file field is set to specific file (which includes Email Addresses).
It will work right.
But your design, Dear Shon, Is more better of course.
This using of row's content for example row2.Email is so interesting.
I tried to use it with ThenRun link, but it doesn't work with this link, and it's natural?!
Tanx shong.