Five Stars ami
Five Stars

[resolved] sending attachment data into email body of TSENDMAIL

Dear Gents/Madam's,
I have a requirement, I am trying to send the attachment data into email body  through TSENDMAIL.
what i am looking for is the HTML code , as i am able to send  the attachment data into email body but its not formatted
example: 
col1   col2  col3
a       b       c
what i am getting is in the email body as :
col1
a
col2
b
col3
c
i need excatly the same o/p in the email body as :
col1   col2  col3
a       b       c
but i am getting :
a
col2
b
col3
c
which is not we are looking  for , i went through all the forums of Talend and i was able to achive till here,
please help me with the formated output,I am attaching the design of my talend job with screen shot of all the components used.
Please help me with the CODE of TSENDMAIL and my job will be done , there is code available in the talend forum someone has put in but its incomplete.
Thanks.
1 ACCEPTED SOLUTION

Accepted Solutions
Community Manager

Re: [resolved] sending attachment data into email body of TSENDMAIL

Hello 
Using a tJavaFlex instead of tJavaRow, in the begin part of tJavaFlex:
String message="col1 col2 col3";
in the main part:
message=message+"\n"+rown.c1+" "+rown.c2+" "+rown.c3;
in the end part:
context.message=message;
on tSendMail, set the Message field with context.message.
Regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
52 REPLIES
Community Manager

Re: [resolved] sending attachment data into email body of TSENDMAIL

Hello 
Using a tJavaFlex instead of tJavaRow, in the begin part of tJavaFlex:
String message="col1 col2 col3";
in the main part:
message=message+"\n"+rown.c1+" "+rown.c2+" "+rown.c3;
in the end part:
context.message=message;
on tSendMail, set the Message field with context.message.
Regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Five Stars ami
Five Stars

Re: [resolved] sending attachment data into email body of TSENDMAIL

Hello 
Using a tJavaFlex instead of tJavaRow, in the begin part of tJavaFlex:
String message="col1 col2 col3";
in the main part:
message=message+"\n"+rown.c1+" "+rown.c2+" "+rown.c3;
in the end part:
context.message=message;
on tSendMail, set the Message field with context.message.
Regards
Shong

Dear shong,
Can you please give the exact code for tjavaflex and what will be code in the tsendmail,
Appreciated your help
Thanks
Amit
Community Manager

Re: [resolved] sending attachment data into email body of TSENDMAIL

Dear shong,
Can you please give the exact code for tjavaflex and what will be code in the tsendmail,
Appreciated your help
Thanks
Amit

Hi Amit
Isn't it clear? I have gave the code of tJavaFlex in my previous post and I use context.message as the code on tSendmail.
Regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Five Stars ami
Five Stars

Re: [resolved] sending attachment data into email body of TSENDMAIL

Dear shong,
Can you please give the exact code for tjavaflex and what will be code in the tsendmail,
Appreciated your help
Thanks
Amit

Hi Amit
Isn't it clear? I have gave the code of tJavaFlex in my previous post and I use context.message as the code on tSendmail.
Regards
Shong
Dear Shong,
Please tell me context,message, i have to declare this in the tjavaflex right ?  and please tell me how will i declare in the context secion of the job .?
Apology if i dint understand your previous post.
Cheers,
Amit
Five Stars ami
Five Stars

Re: [resolved] sending attachment data into email body of TSENDMAIL

Dear shong,
Can you please give the exact code for tjavaflex and what will be code in the tsendmail,
Appreciated your help
Thanks
Amit

Hi Amit
Isn't it clear? I have gave the code of tJavaFlex in my previous post and I use context.message as the code on tSendmail.
Regards
Shong
Dear Shong,
Please tell me context,message, i have to declare this in the tjavaflex right ?  and please tell me how will i declare in the context secion of the job .?
Apology if i dint understand your previous post.
Cheers,
Amit
Thanks shong its working Smiley Happy
really appreciated for your help
Cheers!!
Five Stars ami
Five Stars

Re: [resolved] sending attachment data into email body of TSENDMAIL

Thanks 
Community Manager

Re: [resolved] sending attachment data into email body of TSENDMAIL

Hi 
try this code in the begin part of tJavaFlex:
String message=TalendDate.formatDate("hhaa",TalendDate.getCurrentDate())+" update: "+"\n"+"col1 col2 col3";
----------------------------------------------------------
Talend | Data Agility for Modern Business
Five Stars ami
Five Stars

Re: [resolved] sending attachment data into email body of TSENDMAIL

Thanks shong Smiley Happy
Five Stars ami
Five Stars

Re: [resolved] sending attachment data into email body of TSENDMAIL

Dear Shong, 
i have one requirement , the email which is generated , we want to push this email through HTTP into facebook messanger ,
is this possible ?
Thanks,
Amit
Five Stars ami
Five Stars

Re: [resolved] sending attachment data into email body of TSENDMAIL

Dear Shong,
So basically we want context.message  to be sent to FACEBOOK messanger .
Thanks,
Amit
Community Manager

Re: [resolved] sending attachment data into email body of TSENDMAIL

Hello  
No official component for facebook support so far, I see there is a component call tFBAppData shared on Talend Exchange, I did't test it, so I don't know if it meets your need, you can try it or contact the author of this component for more information.
Regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Five Stars ami
Five Stars

Re: [resolved] sending attachment data into email body of TSENDMAIL

Hello  
No official component for facebook support so far, I see there is a component call tFBAppData shared on Talend Exchange, I did't test it, so I don't know if it meets your need, you can try it or contact the author of this component for more information.
Regards
Shong

Dear Shong ,
Can you please give me his Email id , as in the link has its name but not email address. user id is subro something like this , when i click on it nothing happens
Help will be appreciated 
Thanks
Amit
Community Manager

Re: [resolved] sending attachment data into email body of TSENDMAIL

Hi Amit 
You can add a comment to the component page or try to contact him from their website.
Regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Five Stars ami
Five Stars

Re: [resolved] sending attachment data into email body of TSENDMAIL

Dear Shong,
I will add comment , 
Now i have another requirement , in the mail i am sending o/p as 
now requirement is as such that i will have to compare the previous day update also  
2pm update(29 oct):  (time and date  gets incremented)
col1   col2  col3
a       b       c
2pm update(28 oct):  (time and date  gets incremented)
col1   col2  col3
a       b       c
The process i have it , i just need to merge this two message in one mail , the job which i have i will have to replicate again for the new process and then send the output of both in single mail ...
  and the mail will look like :-
2pm update(29 oct):  (time and date  gets incremented)
col1   col2  col3
a       b       c
2pm update(28 oct):  (time and date  gets incremented)
col1   col2  col3
a       b       c


Please help on this shong....
Regards
Amit
Five Stars ami
Five Stars

Re: [resolved] sending attachment data into email body of TSENDMAIL

Dear Shong,
From two files i will be able to get this is the email Body  :
2pm update(29 oct):  (time and date  gets incremented)
col1   col2  col3
a       b       c
2pm update(28 oct):  Previous day
col1   col2  col3
a       b       c

logic for previous day is already implemented in the query and i am just putting that output of the query in the xls
just need to put that xls output in the email 
col1   col2  col3
a       b       c
col1   col2  col3
a       b       c
Thanks.
Amit
Five Stars ami
Five Stars

Re: [resolved] sending attachment data into email body of TSENDMAIL

bacically 
i want to add context.message  and context.message1 in tsendmail body
Community Manager

Re: [resolved] sending attachment data into email body of TSENDMAIL

bacically 
i want to add context.message  and context.message1 in tsendmail body

Just set the message body as:
context.message+"\n"+context.message1
----------------------------------------------------------
Talend | Data Agility for Modern Business
Five Stars ami
Five Stars

Re: [resolved] sending attachment data into email body of TSENDMAIL

Dear Shong,
i did set it to 
context.message+"\n"+context.message1
But it displays only context.message 2 times , the context.message1 flow is not taken into account
i did exactly , the two flow of the jobs  and both the flows , are on job ok to tsendmail . But i think tsendemail is taking only context.message and not  context.message1
Thanks,
Amit 
Five Stars ami
Five Stars

Re: [resolved] sending attachment data into email body of TSENDMAIL

bacically 
i want to add context.message  and context.message1 in tsendmail body

Just set the message body as:
context.message+"\n"+context.message1
Dear Shong,
My issue is back ..
The mail is trigger twice.


This is my job flow .. I dont know why mail is going twice.
both flow has different files and i an sending both files data into one email actually.
Just email is sent twice dont know the reason .
Please suggest/help
Thanks,
Amit
Five Stars ami
Five Stars

Re: [resolved] sending attachment data into email body of TSENDMAIL

Dear Shong,
Please see Tsendmail component:-

I am receving two mails ideally i should get only one mail :-
output of mails are as follows:-
First mail o/p is :-
Here only message1 gets printed , i dont want this mail .The thing is at a time two mails are generated,
Please help

Thanks.
Amit
Five Stars ami
Five Stars

Re: [resolved] sending attachment data into email body of TSENDMAIL

Dear Shong,
Here is the javaflex code for 1st flow which we resolved , and the second flow :-
First flow javaflex code:
message=message+"\n"+rown.c1+" "+rown.c2+" "+rown.c3;
context.message=message;
Second Flow javaflex code:
message1=message1+"\n"+rown.c4+" "+rown.c5+" "+rown.c6;
context.message1=message1;
Now to tsend mail i am sending :-
"+context.message+" 
"+context.message1+"
I tried using "\n" it throws error
"+context.message+"  +"\n"+
"+context.message1+"
Gives error , now when i try 

"+context.message+" 
"+context.message1+"   in tsend mail it gives me mail 2 times with one message proper output and in another mail i get 
message1 displayed on the mail
Please suggest i need to resolve this issue anyhow.............
Appretiate your reply Shong....
With best regards
Amit
Community Manager

Re: [resolved] sending attachment data into email body of TSENDMAIL

  in tsend mail it gives me mail 2 times with one message proper output and in another mail i get 
message1 displayed on the mail

There must be a job design problem, please upload a screenshot of your job or email it to me. 
----------------------------------------------------------
Talend | Data Agility for Modern Business
Five Stars ami
Five Stars

Re: [resolved] sending attachment data into email body of TSENDMAIL

  in tsend mail it gives me mail 2 times with one message proper output and in another mail i get 
message1 displayed on the mail

There must be a job design problem, please upload a screenshot of your job or email it to me. 

Dear Shong , 
There are two xls files from which data is fetched and put it in one mail , both xls contains 4 lines each , format of the two files are not same , but i am taking 3 columns from both the lines ex:-
file 1:
a  b   c
1  2   3
4  5  6
7  8  9
File 2:
x  y  z
11 2  3
4   5  6
3   4   5
12   3  5
Here is the screen shot of the Entirejob:-
Top flow corresponds to file 1 and bottom flow corresponds to file2. Now i will show u each component inside.
Starting from tfilelist_1:-
tfileinputxls_1:

tfileputputxls_1:
tmap_1:
tjavaflex_1:
Second flow of file2:
tfilelist_2:
tfileinputxls_2:

tfileoutputexcel_2:
tmap_2:

tjavaflex_2:
tsendmail:-
"
"+context.message+"  
 
"+context.message1+" 
"
The thing is independently this jobs works fine with proper output ,   but when i do onsubjobok and on component on both on tsend mail then issue arises, i tried from tsend mail to tfilelist and vice versa 
Please help.
Thanks
Community Manager

Re: [resolved] sending attachment data into email body of TSENDMAIL

Hi 
The emails should be sent after the two sujobs finishes, eg:
tfilelist1...
  |
onsubjobok
  |
tfilelist2...
  |
onsubjobok
  |
tSendmail
In addition, I see you set a fixed value like ''file1.xls" in File Mask field on tFileList, if you just want to read a single file, you don't need tfilelist, set the absolute path on tFileInputExcel.
Regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Five Stars ami
Five Stars

Re: [resolved] sending attachment data into email body of TSENDMAIL

Hi 
The emails should be sent after the two sujobs finishes, eg:
tfilelist1...
  |
onsubjobok
  |
tfilelist2...
  |
onsubjobok
  |
tSendmail
In addition, I see you set a fixed value like ''file1.xls" in File Mask field on tFileList, if you just want to read a single file, you don't need tfilelist, set the absolute path on tFileInputExcel.
Regards
Shong

Thanks shong ...
Five Stars ami
Five Stars

Re: [resolved] sending attachment data into email body of TSENDMAIL

Hi 
The emails should be sent after the two sujobs finishes, eg:
tfilelist1...
  |
onsubjobok
  |
tfilelist2...
  |
onsubjobok
  |
tSendmail
In addition, I see you set a fixed value like ''file1.xls" in File Mask field on tFileList, if you just want to read a single file, you don't need tfilelist, set the absolute path on tFileInputExcel.
Regards
Shong

Dear Shong,
To wrap up this issue , 
i need one more help 
i am sending the context.message variable to the link:
"https://api.telegram.org/bot32248:AAETfC4RyKIGcDTrsVDzPgiRKua0daUKORg/sendmessage?chat_id=3231098&te..."
i have change the bot and chat_id numbers as its my telegram id .

This is the same job just added the thhtp component at last as i want to send this variable message over to telegram messanger
please note:
"https://api.telegram.org/bot32248:AAETfC4RyKIGcDTrsVDzPgiRKua0daUKORg/sendmessage?chat_id=3231098&te..."
when i run this , hi goes to the messanger 
but when i execute
"https://api.telegram.org/bot32248:AAETfC4RyKIGcDTrsVDzPgiRKua0daUKORg/sendmessage?chat_id=3231098&te..."
The message goes as : context.message to the telegram messanger i want the value of  context.message to go 
am i doing anything wrong ?
or is there any component like tjava through that i can send ? any help from you on this?
Help in this will be really appreciated...

Please see the telegram messanger snapshot: hi and hello gets displayed but not the value of the variable context.message


thanks,
Amit
Five Stars ami
Five Stars

Re: [resolved] sending attachment data into email body of TSENDMAIL

Dear Shong,
Please leek at the new job which i created  , it sends the variable value context.message to the email body , now at the end of the job have added thhtp component , the link is of telegram messanger with chat id and the text:-


Now thhtp component:-


The link is :
"https://api.telegram.org/bot322480890:AAETfC4RyKIGcDTrsVDzPgiRKua0daUKORg/sendmessage?chat_id=323109..."
But when i use the link as 
"https://api.telegram.org/bot322480890:AAETfC4RyKIGcDTrsVDzPgiRKua0daUKORg/sendmessage?chat_id=323109827&text=Hi
The message is sent to telegram messanger from this component as HI
also hello goes 
but when i try to send as :

"https://api.telegram.org/bot322480890:AAETfC4RyKIGcDTrsVDzPgiRKua0daUKORg/sendmessage?chat_id=323109..."
only context.message appears in the messenger ,but when i remove the thhtp component , then in mail the context.message variable is printed in the mail body correctly.
i dont know why through link the variable value is not send only context.message is sent , please see below screen shot of telegram messanger:



Any other component we can send this tjava or any other commond ? curl i dont know
Help will be appreciated.
Thanks
Amit
Five Stars ami
Five Stars

Re: [resolved] sending attachment data into email body of TSENDMAIL

Dear Shong,
Any idea on the above please?
Regards,
Amit
Community Manager

Re: [resolved] sending attachment data into email body of TSENDMAIL

Hi 
The URL is wrong, the context variable should be used without double quote.
"https://api.telegram.org/bot322480890:AAETfC4RyKIGcDTrsVDzPgiRKua0daUKORg/sendmessage?chat_id=323109...
----------------------------------------------------------
Talend | Data Agility for Modern Business