1

I am trying to use Talend Data Integration in order to take an Excel spreadsheet's rows and use the emails listed in the spreadsheet in order to get a list of addresses for the tSendMail component to use.

So far, I have: tFileInputExcel -> tFlowToIterate -> tSendMail.

I have already looked at these two threads but have had no luck in understanding where I should go from where I am currently.

Community
  • 1
  • 1
boospr
  • 11
  • 1
  • 2

1 Answers1

2

You seem to be on the right track.

As you gathered, you need to trigger the tSendMail component iteratively.

Talend's normal row connectors between components passes a flow of data from one component to the next. If you use an iterate link then instead it will send just the first row for processing to the rest of the subjob.

Here you basically have a list of email addresses in an Excel file so you want to iterate through the list, passing them to the tSendMail component.

Simple job setup and layout

If you connect a tFlowToIterate component to your tFileInputExcel component then the tFlowToIterate will effectively just trigger the tSendMail component once for each row of data in the input file. It doesn't actually pass any data directly.

Instead, the tFlowToIterate moves the data into the globalMap where it can be read from by any downstream components. To use the data you would access it with something like ((String)globalMap.get("row1.email")). If you press ctrl+space on, for example, the "To" field in the tSendMail component Talend should show a list of available variables:

Variables available when pressing ctrl+space

Here you can see some metadata about the tFlowToIterate_1 component but also the "email" column that is the sole column of the Excel file's schema. If we select this then it will automatically give us the globalMap.get for the component (which in my case is the aforementioned ((String)globalMap.get("row1.email")) because I left the checkbox of the tFlowToIterate as default).

Then it's just a matter of properly configuring your tSendMail component and using the value from the globalMap as your "To" property:

tSendMail configuration with the data from the email field being used for the "To" property

Using this same idea we can do more complicated things too. For example we might have a custom message body in the Excel file and also the name of the recipient (which could also have potentially have been parsed from the email address prior to the tFlowToIterate) so we can then do something like:

A more complicated tSendMail configuration that uses the customer name in the email subject and then a custom message body taken from the Excel file

ydaetskcoR
  • 53,225
  • 8
  • 158
  • 177