Thursday, January 05, 2017

Talend Project - Send mail (tSendMail component)

Talend's tSendMail component can be used to send HTML formatted emails. this Video demonstrates framing a HTML formatted text using the project we were working on.

This is the code that we used in tJavaRow component to extract the rating and create an email body that lists and changes compared to previous rating. Please follow the video get a complete understanding.

/* -- Code from https://www.youtube.com/channel/UCT3bqK2QL93j-IFYFYbvjWQ ---- */ String wholepage; String ratings; wholepage=input_row.document.toString(); int pos=wholepage.indexOf("composite_val"); ratings=wholepage.substring(pos,pos+250).replaceAll("[\\[\\]\"]", "").replaceAll(" \n", " ").replaceAll(" composite_val_vgm",""); //output_row.document = ratings; String allratingsonly=""; String[] splitratings = ratings.split("composite_val>"); int i=0;String EmailText="Ratings for : " +context.stock +"" ;for (String eachratingrow : splitratings)    if (eachratingrow.length()>0)   { allratingsonly=allratingsonly+";"+ eachratingrow.charAt(0)+"";     //allratingsonly=allratingsonly+eachratingrow+"**;";      if (i==0){  output_row.z_growth_rating=Character.toString(eachratingrow.charAt(0));  
  if ( eachratingrow.charAt(0)>input_row.growth_rating.charAt(0))  {   EmailText=EmailText+"Growth rating reduced from " +input_row.growth_rating+ " To "+ eachratingrow.charAt(0)+"
"; 
";   }
      if ( eachratingrow.charAt(0)    {   EmailText=EmailText+"Growth rating improved from " +input_row.growth_rating +" To "+ eachratingrow.charAt(0)+"
";  
";      }  }    if (i==1){ output_row.z_momentum_rating=Character.toString(eachratingrow.charAt(0));   if ( eachratingrow.charAt(0)>input_row.momentum_rating.charAt(0))  {   EmailText=EmailText+"momentum rating reduced from " +input_row.momentum_rating+ " To "+ eachratingrow.charAt(0)+"
"; 
";   }
      if ( eachratingrow.charAt(0)    {   EmailText=EmailText+"momentum rating improved from " +input_row.momentum_rating +" To "+ eachratingrow.charAt(0)+"
";  
";      }  }  if (i==2){ output_row.z_value_rating=Character.toString(eachratingrow.charAt(0));   if ( eachratingrow.charAt(0)>input_row.value_rating.charAt(0))  {   EmailText=EmailText+"value rating reduced from " +input_row.value_rating+ " To "+ eachratingrow.charAt(0)+"
"; 
";   }
      if ( eachratingrow.charAt(0)    {   EmailText=EmailText+"value rating improved from " +input_row.value_rating +" To "+ eachratingrow.charAt(0)+"
";  
";       }  }     if (i==3){   output_row.z_vgm_rating=Character.toString(eachratingrow.charAt(0));   if ( eachratingrow.charAt(0)>input_row.vgm_rating.charAt(0))  {   EmailText=EmailText+"vgm rating reduced from " +input_row.vgm_rating+ " To "+ eachratingrow.charAt(0)+"
"; 
";   }
      if ( eachratingrow.charAt(0)    {   EmailText=EmailText+"vgm rating improved from " +input_row.vgm_rating +" To "+ eachratingrow.charAt(0)+"
";  
";       }  }  i++;
    } 

output_row.EmailText=EmailText;/* - End of Code from https://www.youtube.com/channel/UCT3bqK2QL93j-IFYFYbvjWQ --*/



If you haven't visited this project from the beginning, Here is the first post about it in this blog - http://sanjaykattimani.blogspot.com/2016/12/talend-project-to-parse-webpage-zackscom.html

No comments: