Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
As a strating point you case copy/paste the following piece of Java code into a tJavaRow connected to to your data flow (for ex. tOracleInpput-->tJavaRow).
String msg = ((String)globalMap.getOrDefault("mailMessage", "<TABLE border=0 cellspacing=1px>" + "<TR><TD>ID</TD><TD>Error</TD><TD>Date</TD></TR>"));
msg = msg + "<TR><TD>" + row1.ID + "</TD><TD>" + row1.Error + "</TD><TD>" + row1.Date + "</TD></TR>"
globalMap.put("mailMessage", msg);When the subjob is finish (onSubjobOK), a tSendMail will send the email using the content of the global variable "mailMessage" as as the message using the following syntax:
((String)globalMap.get("mailMessage"))You can enrich the table with colors and so on.
As a strating point you case copy/paste the following piece of Java code into a tJavaRow connected to to your data flow (for ex. tOracleInpput-->tJavaRow).
String msg = ((String)globalMap.getOrDefault("mailMessage", "<TABLE border=0 cellspacing=1px>" + "<TR><TD>ID</TD><TD>Error</TD><TD>Date</TD></TR>"));
msg = msg + "<TR><TD>" + row1.ID + "</TD><TD>" + row1.Error + "</TD><TD>" + row1.Date + "</TD></TR>"
globalMap.put("mailMessage", msg);When the subjob is finish (onSubjobOK), a tSendMail will send the email using the content of the global variable "mailMessage" as as the message using the following syntax:
((String)globalMap.get("mailMessage"))You can enrich the table with colors and so on.
Great!
For the rest, this is a HTML question, not a Talend one.
However, have a look at "TABLE border" parameter.
Hi,
I Tried to to develop a job through talend using the below java code. But i face the below issues
Can you please help me to know the configuration of tJavaRow and tSendMail
Hi @SwatiShashwati in the original post the second line in the code
msg = msg + "<TR><TD>" + row1.ID + "</TD><TD>" + row1.Error + "</TD><TD>" + row1.Date + "</TD></TR>"
is missing an ';' at the end. to complete the Java statement.
As an aside I'm wondering why @TRF you didn't use a tJavaFlex component so the this would then become something like this ( note not tested directly )
Start Code
String msg = ((String)globalMap.getOrDefault("mailMessage", "<TABLE border=0 cellspacing=1px>" + "<TR><TD>ID</TD><TD>Error</TD><TD>Date</TD></TR>"));
Main Code
msg = msg + "<TR><TD>" + row1.ID + "</TD><TD>" + row1.Error + "</TD><TD>" + row1.Date + "</TD></TR>";
(note additional ';' at end )
End Code
globalMap.put("mailMessage", msg);
Hi Sir,
Can you help me to reset or clear the table for every iterate?
tDBInput row1 (main) -> tFlowIterate -> tDBInput row2 (main) -> tJavaRow1 - >tsendMail
My problem is the datatable in email are embedded from the previous data.
Itry to put msg =""; in javarow code but I get the same output.
Thank you
String msg = "";
msg =((String)globalMap.getOrDefault("mailMessage", "<TABLE border=1 cellspacing=1px>" + "<TR><TD>EMPLOYEE_NO</TD><TD>EMPLOYEE_NAME</TD><TD>EVENT</TD><TD>DATE</TD><TD>TIME</TD><TD>VOID_LINK</TD></TR>"));
msg = msg + "<TR><TD>" + row1.EMPLOYEE_NUMBER + "</TD><TD>" + row1.EMPLOYEE_NAME + "</TD><TD>" + row1.EVENT + "</TD><TD>" + row1.DATE_TRANS + "</TD><TD>" + row1.TIME + "</TD><TD>" + row1.VOIDLINK + "</TD></TR>";
globalMap.put("mailMessage", msg);
Because your setting the value into the globalMap - it will persist across iterations. If you don't want this you might have
1) use the index of the iteration in the name of the field ( i.e. "mailMessage_" + index ) or
2) store an arraylist in the globalMap, and use the index of iteration to retrieve the correct value for the current iteration. This will depend on how many iterations you are running - maybe bad idea if doing lots. or
3) issue here is that you probably should just construct your string in tJavaRow1 and just save it to => globalMap.put("mailMessage", msg) i.e. don't do a globalMap.getOrDefault as this will return the value created via the first iteration for every subsequent iteration. You don't need it. just construct new string and globalMap.put it - every iteration will overwrite the previous.
Hope this helps.....