Solved

Gathering info and sending mail in java

Posted on 2011-09-16
26
205 Views
Last Modified: 2012-05-12
Hi Experts...
I have a java program which does a couple of operations and produces results in form of reports.
What i want to do is gather all the output produced in the program and covert it into a pdf format and send the pdf format data to certain people via mails as an attachement.
Please help...
0
Comment
Question by:gaugeta
  • 9
  • 6
  • 6
  • +1
26 Comments
 
LVL 47

Accepted Solution

by:
for_yan earned 500 total points
ID: 36547951


wwell, in order to create PDF reports you may want to use iText

http://itextpdf.com/

in 0rder to send emails (including emails with attachment) you ned to use JavaMail

0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 36547955
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36547958

download JavaMail from here:
http://www.oracle.com/technetwork/java/javamail/index-138643.html
you'll need mail.jar and activation.jar to have in the classpath to send emails from java program
0
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 
LVL 40

Expert Comment

by:gurvinder372
ID: 36547967
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 36548015
0
 

Author Comment

by:gaugeta
ID: 36548033
@all:Thanks for the reply.
I want everything printed on the screen using SOP's to be created as a pdf file.
How do i do this.
Please help...
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 36548039
You need to send that information using ajax post and then generate PDF file out of it
0
 

Author Comment

by:gaugeta
ID: 36548082
@gurvinder372:Thanks for the reply.
Could you give a sample for the same.
Please help...
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 36548088
>>I want everything printed on the screen using SOP's to be created as a pdf file.

You need to use a pdf api (as mentioned above) and append to a document instead of SOPping
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 36548094
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 36548108
What exactly does Ajax have to do with a Java application?
0
 

Author Comment

by:gaugeta
ID: 36548161
@CEHJ:Thanks for the reply.
I got that instaead of SOP'ing i would be appending the same to a file.
The what do i do with the file to be converted to a pdf and sent as an attachment in a mail.
Please help...
0
 

Author Comment

by:gaugeta
ID: 36548170
@gurvinder372:I did not get why do we use AJAX here.
Can you please explain.Thanks for the reply...
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 36548294
<<What exactly does Ajax have to do with a Java application?>>
He wants to send information printed on his webpage to the server, so he needs to submit the information. He can use ajax for the same.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 36548310
>>He wants to send information printed on his webpage to the server

I don't see the Web mentioned anywhere ...
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 36548330
Well, he said that he wants to fetch what is printed on screen. So, i thought he was talking about web page screen.

0
 

Author Comment

by:gaugeta
ID: 36548395
@CEHJ: I got that instead of SOP'ing i would be appending the same to a file.
The what do i do with the file to be converted to a pdf and sent as an attachment in a mail.
Please help...
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 36548433
You wouldn't be appending to a file, you'd be appending to a document and then turning it into a file. Make a standalone mthod that does that first, that you can integrate into the one that sends the mail
0
 

Author Comment

by:gaugeta
ID: 36564444
@all:Can itext be used to capture the program's output in .doc or .txt format instead of pdf.
Please help...
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36564450
in order tio capture output in .txt format - you don't need
and special effort - any string is in .txt format

I think you can use Apache POI to make .doc format out of the .txt

http://poi.apache.org/
0
 

Author Comment

by:gaugeta
ID: 36564452
@for_yan:Actually i have to format the output in form of tables with certain fonts and colors.
So which is the best option for the same.
Please help...
0
 

Author Comment

by:gaugeta
ID: 36564460
@for_yan:Can we use itext for capturing data in for of .doc instead of pdf.
Since its rich and convenient.
Please help...
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36564464
iText is for PDF, maybe there is some option bfor Word but I'm not sure

Each has its own tool.
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36564467

That's waht they write in case you want iText:
http://stackoverflow.com/questions/203174/whats-a-good-java-api-for-creating-word-documents

    After a little more research, I came across iText, a PDF and RTF-file creation API. I think I can use the RTF generation to create a Doc-readable file that can then be edited using Doc and re-saved.

    Anyone have any experience with iText, used in this fashion?

Bill, the POI and iText API are very similar from a programming perspective. I've worked with both in the past and found them both easy to use and well documented.

With iText you gain the advantage of being able to switch between formats (RTF and PDF) with minor change to the code. If I remember correctly the content is laid out using the same calls and then set as PDF or RTF using a few lines of code.

However I believe the formatting in RTF is limited compared to DOC. I don't know if you'll be able to implement the advanced features you are looking for (tables, inline images) without a decent amount of hassle, if at all.

Given what you said that about HWPF not having enough functionality for your needs (I've only dealt with the Excel side of POI) your best bet may be to convince the powers that be that PDF is the best technology for the job.
0
 

Author Comment

by:gaugeta
ID: 36564603
@for_yan:Could you give some sample file for poi doc generation.
Please help...
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36564646
see the posting to your next question
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
windows explorer path to command prompt 5 54
How to execute a Python program and gather return output in Java 2 40
runtime exception 2 41
Setup GlassFish 4 21
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question