Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] Problem with tSendMail and extern variables in properties file

Hi,
I try to use the component tSendMail with variables from an external file, but nothing goes right...
So I have
tFileInputProperties_1 ====Main====>tSetGlobalVar_1
   ||OnSubJobOk
   ||
tSendMail


In tFileInputProperties_1 :
File format : .properties
file Name: "./emailDetails.properties"



In tSetGlobalVar_1
Key : "row1.key"
Value : "row1.value"



In tSendMail
To : ((String)globalMap.get("To"))
From : ((String)globalMap.get("From"))

I have also try that:
To : ((String)globalMap.get("row2.value"))
From : ((String)globalMap.get("row1.value"))



In emailDetail.properties
From = abc@abc.com
To= sos@sos.net
host=smtp.gmail.com
port= 465
...


What's o the correct method?
Thank's
Burnside.

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hi,

I have solved my problem with this method.

tFileInputExcel_1 ---Main--- tFlowToIterate_1 ---Iterate--- tFixedFlowInput_1 --- Iterate --- TSendMail_1
tFileInputExcel_1 : The xls file with the values
tFlowToIterate_1 : Key="Mail" and value=Mail
tFixedFlowInput_1 : mode= Use Single Table
                             values=
                             |_>Column =>Mail
                             |_>values =>((String)globalMap.get("Mail"))
TSendMail_2 : Field to : ((String)globalMap.get("Mail"))


I join a print screen of the dashboard.

0683p000009MGg4.png
Hope It help you.
                 

View solution in original post

5 Replies
willm1
Creator
Creator

It looks like because you're using global variables, you're not passing the right key/value to the right global variable. Looks like you might have to do so conditionally (if key = "To" then load to variable "To" etc...). I suspect that if you were to print out the values of your global variables, you'd find that only the last set in your properties file stuck. It's always good practice to print out the values of your variables (System.out.println("key: " +  ((String)globalMap.get("To")) )...


An alternative to using global variables would be to use context variables. Context variables are global variables whose values can be set outside the Talend job - from a file, like you're doing. Because the key/value pairs in the file map to key/value pairs in the job, it makes loading the values very easy. And, there's a component for doing so. As shown below, create context variables in your job, read the values from the file, connect them to a tContextLoad, select options to print the values - so you can confirm that your job is using the right values. 


0683p000009MGfz.png 0683p000009MGXh.png 0683p000009MGYQ.png
Anonymous
Not applicable
Author

HI,
Thank's for your answer, but I'm new and I don't know yet everything...and english is not my mother language.
Is it possible to have an example from an xls file?
Ot just to have a vue from the dashboard?
regards
Burnside.
Anonymous
Not applicable
Author

Hi Burnside,

Please take a look at a related forum:
https://community.talend.com/t5/Design-and-Development/resolved-need-to-send-the-data-of-tLogRow-to-tSendMail/m-p/70061

Best regards
Sabrina
Anonymous
Not applicable
Author

Hi,

I have solved my problem with this method.

tFileInputExcel_1 ---Main--- tFlowToIterate_1 ---Iterate--- tFixedFlowInput_1 --- Iterate --- TSendMail_1
tFileInputExcel_1 : The xls file with the values
tFlowToIterate_1 : Key="Mail" and value=Mail
tFixedFlowInput_1 : mode= Use Single Table
                             values=
                             |_>Column =>Mail
                             |_>values =>((String)globalMap.get("Mail"))
TSendMail_2 : Field to : ((String)globalMap.get("Mail"))


I join a print screen of the dashboard.

0683p000009MGg4.png
Hope It help you.
                 
Anonymous
Not applicable
Author

Hi Burnside,

Thanks for your feedback and sharing your solution with us.

Best regards
Sabrina