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 :-)

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 :-)

Highlighted
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

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

An API-First Approach to Modernizing Applications

Learn how to use an API-First Approach to Modernize your Applications

Watch Now

Talend API Designer – Technical Overview

Take a look at this technical overview video of Talend API Designer

Watch Now

Getting Started with APIs

Find out how to get started with APIs

Read