Skip to main content
Announcements
A fresh, new look for the Data Integration & Quality forums and navigation! Read more about what's changed.
cancel
Showing results for 
Search instead for 
Did you mean: 
joe86
Contributor

Trigger mail only if Attachment is not empty

Hi All,

I need to send a mail only when the attachment is having values. If the attachment is empty, i should skip sending mail. I checked advance setting of tSendMail and found no options to do so. one option that comes to my mind is to load the output to a table and take count of the table and do a workaround.

is there any other option in talend?? 

Labels (2)
20 Replies
joe86
Contributor
Author

got the "if" condition component tab.

0683p000009M1GI.jpg

is the code correct??  or any java like code should be given here??

 

joe86
Contributor
Author

jsut now saw that and then ur post 0683p000009MACn.png
Anonymous
Not applicable

You can check the if based on the global variable. It will be more appropriate.

 

Warm Regards,

 

Nikhil Thampi

joe86
Contributor
Author

@nthampi & @manodwhb

 

thanks a lot to both of you. All ideas of yours are working. but problem in my side is, 

the file size is not getting low if the data is available or not.

Actually, if the output is zero, only the  "headers" will be available in the output file and size is 4kb.

If 4 rows are returned, then too the the size is 4kb. Only when 5 rows are returned, then i get size as 5kb.

 

I tried below option:

Select "Don't generate empty file" in the output file and 

Select "Die if attachment file does not exist" in tSendMail.

Since i am using tLogCatcher, I will not be able to use above two options either.

0683p000009M1GX.jpg

 

any other options you both have other than checking file size or any ways??

manodwhb
Champion II

@joe86,better to go with .txt or .csv file,so you can easily,identify the file size. 

joe86
Contributor
Author

@nthampi & @manodwhb

 

as told, i took another output as ".csv" file (just to check the size of my output file) and gave the flow as below:

0683p000009M1Ba.jpg

and in tSetGlobalVar, i gave Key as "K1" and value as "row2.size". And in the "if" component I gave as "globalMap.get("K1") > 0".

But i got error as below:

 

"The operator > is undefined for the argument type(s) Object,int"

can you please help me on this fix??

 

Note: The tLogRow jobs are given just to check if the tSetGlobalVar produces output as required.

manodwhb
Champion II

@joe86,use this.

 

((Integer)globalMap.get("K1")) > 0

joe86
Contributor
Author

got below error:

0683p000009M1HG.jpg

below is the value given in tSetGlobalVar:

 

0683p000009M1Fg.jpg

is this correct? Not sure, where am i making wrong.

joe86
Contributor
Author

@nthampi @manodwhb

after giving the "if" condition as ((int)globalMap.get("K1"))>0, i am getting below error.

java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer

any idea about this??

manodwhb
Champion II

@joe86,row2.size not needed in single or double quotes.