Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I'm trying to rename file attachments from email files, pulled with tFileInputMail (from tPop), based on the subject line.
I found this: https://community.talend.com/t5/Design-and-Development/Save-and-Rename-mail-attachments/td-p/112143
However I can't see the images that contain the solution and I am a bit lost on how to pass the values to tFileCopy (tJavaRow before to change name).
I'm thinking something like:
tPop ---- iterate ---> tFileInputMail --- (row) ---> tJavaRow -----> tFlowtoIterate ----> tFileCopy
But I can't extract/pass the attachment name from tFileInputMail.
Thanks.
Regards,
V
Hi med,
Many thanks for your help. I've finally got back to this and have cracked it with your help/guidance.
I now have it working with (after pulling all emails into a folder):
tFileList -(iterate)-> tFileInputMail -(row)> tJavaRow -> onComponentOK -> tFileList -(iterate)-> tFileCopy
*onComponentOk can be replaced with -(row)> tFlowtoIterate -(iterate)->
tJavaCode: globalMap.put("subject",row1.subject)
tFileCopy:
Note: we have to use tJavaRow because "Where is tJava used in the Job design: The Java code inserted through the tJava is executed first but only once in the subjob" - so we couldn't read the initial row value.
Regards,
Vitor Lopes
Hello,
When you retrieve the attachment files using the tFileInputMail you specify the folder Path and not the File attachment name.
So in your case, you can develop 2 subjobs :
1- Retrieve the attachments files and put them in the folder.
2- Use tFilelist to fetch the folder and in each iteration you can uste tCopy to rename the files.
BR,
Hello,
In fact
tFileInputMail allow you to retrieve the File in specific folder (you specify the folder).
you can use directly :
tFileInputMail (On component OK) -> tfilelist (specify the folder which contain the files) -> tfilecopy
No need to use tJavaRow.
BR,
Med
Hello,
Ok i get what you need.
So the idea is to retrieve in each iteration the subject and then use this subject to rename your files.
so you can use tFileinputMail (iterate)==>tJava(iterate)==>tFilelist==>tCopy
beause you cant use tJavaRow in iterate.
GoodLuck
OK, so nearly there.
Question, how do I access the subject in tJava?
Many thanks for your time, and help so far
Cheers,
V
Hello,
I try to access to the subject using tJava but no way (the variables are not available for this component).
Try to use tFlowIterate ( tFileInputMail (main_row)==>tFlowIterate(titerate)==>tCopyFile
Let me know if it works.
Hi med,
Many thanks for your help. I've finally got back to this and have cracked it with your help/guidance.
I now have it working with (after pulling all emails into a folder):
tFileList -(iterate)-> tFileInputMail -(row)> tJavaRow -> onComponentOK -> tFileList -(iterate)-> tFileCopy
*onComponentOk can be replaced with -(row)> tFlowtoIterate -(iterate)->
tJavaCode: globalMap.put("subject",row1.subject)
tFileCopy:
Note: we have to use tJavaRow because "Where is tJava used in the Job design: The Java code inserted through the tJava is executed first but only once in the subjob" - so we couldn't read the initial row value.
Regards,
Vitor Lopes