Email csv file from local machine using cMail component throws Null Pointer

Five Stars

Email csv file from local machine using cMail component throws Null Pointer

Hi 

I am trying to send the CSV file from my local machine via email using cMail component. The code in my cProcessor is below is :

import java.io.File;

String path = "C:\\Users\\Talend\\Downloads\\Report_20190226.csv";
exchange.getIn().addAttachment(path.substring(path.lastIndexOf("\\")+1), new javax.activation.DataHandler(new javax.activation.FileDataSource(path)));
exchange.getIn().setBody("Hello");
System.out.println(path);

but it gives the following exception: 

java.lang.NullPointerException

Please help me where my exchange is getting null.
The flow is shown in the image attached.

Thanks

Employee

Re: Email csv file from local machine using cMail component throws Null Pointer

Hi,

 

   Before doing the processing, could you please print and verify whether the file names are parsed in the right way?

 

   Please assign the data to a variable and print the steps like last index parse. It should give you a clue.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved :-)


Warm Regards,
Nikhil Thampi
Please appreciate our members by giving Kudos for spending their time for your query. If your query is answered, please mark the topic as resolved :-)
Five Stars

Re: Email csv file from local machine using cMail component throws Null Pointer

Hi Nikhil Thampi,

I am getting the path and file name but not able to receive email with attachment.
Employee

Re: Email csv file from local machine using cMail component throws Null Pointer

Hi Ameen,

 

    Could you please provide the component screenshots also for the problematic components?

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved :-)


Warm Regards,
Nikhil Thampi
Please appreciate our members by giving Kudos for spending their time for your query. If your query is answered, please mark the topic as resolved :-)
Five Stars

Re: Email csv file from local machine using cMail component throws Null Pointer

Hi Nikhil,

I have already attached the image in my first post. Please look at that.
One more thing it is from Talend 5.3

What’s New for Talend Spring ’19

Watch the recorded webinar!

Watch Now

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch

Downloads and Trials

Test drive Talend's enterprise products.

Downloads

Definitive Guide to Data Integration

Practical steps to developing your data integration strategy.

Download