• Post Reply Bookmark Topic Watch Topic
  • New Topic

building an html file dynamically and sending it as an attachment  RSS feed

 
pulijala hari
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have to develop a program where i have to build an html file from a string that is formed by conctenating html tags based on some conditions.
Could any body give me a sample program as how to build an html file dynamically and then send it as an attachment in java?

regards,
hari
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Building an HTML string is just like any other string. You need to know what you want the HTML to look like and then just put the bits together.

html = "<html><body>Hello " + name + ", how are you?</body></html>";

If you have lots parts to stick together, look at StringBuffer.append() instead of string concatenation.

From "attachment" I infer mail, which I've never done from Java. I'll let somebody else tackle that bit. There is another forum for "other APIs" that mentions mail in the name, I think.
 
Mathias Nilsson
Ranch Hand
Posts: 367
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can download the javamail api from sun here. There is plenty of examples on how to send mail and attach files etc.

// Mathias
 
payal agrawal
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Below are the links to build HTML file and Send Email from java class.

Creating PDF, RTF or HTML document from a Java class at runtime
http://www.java-tips.org/content/view/130/29/

Manipulating PDF, RTF, or HTML documents with Java
http://www.java-tips.org/content/view/131/29/

Adding Javascript to HTML documents with Java
http://www.java-tips.org/content/view/132/29/

Sending e-mail using JavaMail API
http://www.java-tips.org/content/view/129/29/
[ October 15, 2005: Message edited by: payal agrawal ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!