Author |
Message
|
premji |
Posted: Mon Jan 19, 2015 8:43 am Post subject: Dynamically reading files & emailing them csv as attachm |
|
|
Acolyte
Joined: 01 Jul 2013 Posts: 64
|
Hi All,
How can we emailing them csv file as attachment by using Java Compute node. |
|
Back to top |
|
 |
mqjeff |
Posted: Mon Jan 19, 2015 8:55 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
By constructing the necessary logical message tree. |
|
Back to top |
|
 |
premji |
Posted: Mon Jan 19, 2015 9:00 am Post subject: Dynamically reading files & emailing them csv as attachm |
|
|
Acolyte
Joined: 01 Jul 2013 Posts: 64
|
Hi
Thank you for your quick reply. I have tried to build but I am not able to send CSV format file |
|
Back to top |
|
 |
mqjeff |
Posted: Mon Jan 19, 2015 9:02 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Why aren't you?
What did you do to build a CSV format?
What are you using to send an email? |
|
Back to top |
|
 |
premji |
Posted: Mon Jan 19, 2015 9:14 am Post subject: Dynamically reading files & emailing them csv as attachm |
|
|
Acolyte
Joined: 01 Jul 2013 Posts: 64
|
Hi
I have requirement to send CSV file as attachment, if I converted CSV file to byte code format I can send file but original content I am not able to send as attachment. |
|
Back to top |
|
 |
mqjeff |
Posted: Mon Jan 19, 2015 9:20 am Post subject: Re: Dynamically reading files & emailing them csv as att |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
premji wrote: |
I have requirement to send CSV file as attachment |
Ok. What steps have you taken to accomplish that requirement?
premji wrote: |
original content I am not able to send as attachment. |
Why not? What happens?
What steps have you taken, so far? |
|
Back to top |
|
 |
premji |
Posted: Mon Jan 19, 2015 10:16 am Post subject: Dynamically reading files & emailing them csv as attachm |
|
|
Acolyte
Joined: 01 Jul 2013 Posts: 64
|
Hi
First I have declared as MIME type and Content Type as MIME type.
This below code I have written so far. parts is child of MIME type. Here if I added string value instead of bytes I got exception.
part = parts.createElementAsLastChild(MbElement.TYPE_NAME, "Part", null);
part.createElementAsLastChild(MbElement.TYPE_NAME_VALUE, "Content-Type", "text/plain; " +
"charset=us-ascii;name=attachment.xlsx");
part.createElementAsLastChild(MbElement.TYPE_NAME_VALUE, "Content-Transfer-Encoding", "8bit");
data = part.createElementAsLastChild(MbElement.TYPE_NAME, "Data", null);
blob = data.createElementAsLastChild("BLOB");
String sourceName= "source file path";
inputStream = new BufferedReader(new FileReader(sourceName));
String l;
while ((l = inputStream.readLine()) != null) {
attachment2Text = attachment2Text + l + "\r\n";
}
blob.createElementAsLastChild(MbElement.TYPE_NAME_VALUE, "BLOB", attachment2Text.getBytes("UTF8"));
inputStream.close(); |
|
Back to top |
|
 |
|