[resolved] tSendMail - Get message text from context variable

One Star

[resolved] tSendMail - Get message text from context variable

Hello
i have the following problem:
i want to send my output file per email. For the basic settings i want to use context variables. It works fine as long as i don't use context variables for the subject or the message field (see pic 3).
When i use context variables for these two fields, i get the following error (see pic 1):

Exception in component tSendMail_1
javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 501 5.1.3 Invalid address
at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1196)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:584)
at javax.mail.Transport.send0(Transport.java:169)
at javax.mail.Transport.send(Transport.java:98)
at data_auditing.webpxe_mka_group_0_1.webpxe_mka_group.tSetGlobalVar_1Process(webpxe_mka_group.java:2997)
at data_auditing.webpxe_mka_group_0_1.webpxe_mka_group.tHashInput_2Process(webpxe_mka_group.java:4528)
at data_auditing.webpxe_mka_group_0_1.webpxe_mka_group.tMysqlInput_1Process(webpxe_mka_group.java:9717)
at data_auditing.webpxe_mka_group_0_1.webpxe_mka_group.runJobInTOS(webpxe_mka_group.java:11238)
at data_auditing.webpxe_mka_group_0_1.webpxe_mka_group.main(webpxe_mka_group.java:10923)
Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 501 5.1.3 Invalid address
at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1047)
... 8 more
Failed to send mail

What am I doing wrong? Is it not possible to set the subject and message text per context variables?

Accepted Solutions
One Star

Re: [resolved] tSendMail - Get message text from context variable

Ok problem solved, was just a syntax error, like you expect.
Thanks you all for the help :-)

All Replies
Seventeen Stars

Re: [resolved] tSendMail - Get message text from context variable

Your problem is definitely not the usage of Context variables. Thats absolute normal and in my job it is common. The problem is only the content of the variables. The addresses must be concatenate with a comma and not a semicolon (I do not see your content but this is a common mistake).
Community Manager

Re: [resolved] tSendMail - Get message text from context variable

Hi
As jlolling said, the problem is only the content of the variables, for testing, use a tJava before tSendMail component to print the value of context variable and validate the value is set correctly or not. Eg:
....tSetGlobalVar--oncomponentok--tJava--tSendMail....
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] tSendMail - Get message text from context variable

Thanks for your replies.
I set the content of the variable to "test" and validate the value with tJava, but the problem still exists. I also tried to insert the value of the variable to a global var and call it, but the same error appears
Community Manager

Re: [resolved] tSendMail - Get message text from context variable

Hi
If the email address is set to "test", it is obviously an invalid address. A standard email address should be like: xxxx@xxx.xxx
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] tSendMail - Get message text from context variable

Oh no, the problem is not the email adress! This works fine, the only problem is when i want to set the email message, the text of the email, per context variable! I set the message text to "test", not the email adress!
If i insert the text manually, all works fine and the mail will be sent. but when i get the messsage text (not the email adress!) from a context variable or a global variable the program crash and throw the error i send in my first post
Seventeen Stars

Re: [resolved] tSendMail - Get message text from context variable

hi all,
As Shong said, catch the value you've got in context.email_cc thanks a tJava component to be sure about it.
System.out.println(context.email_cc);

And you don't have to use a row connector to tSendMail !
regards
laurent
One Star

Re: [resolved] tSendMail - Get message text from context variable

Ok problem solved, was just a syntax error, like you expect.
Thanks you all for the help :-)