Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Other JSE/JEE APIs and the fly likes Generate Email body Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Generate Email body" Watch "Generate Email body" New topic
Author

Generate Email body

Sahana Hegde
Ranch Hand

Joined: Jan 27, 2008
Posts: 67
Hello,

How can I generate the email body to be sent with some styles.

For now I am just creating a string and appending information to the string.I am appending a \r where I need a gap.

The email is generated something like this.

----------------------
Name : sah

Forum : javaranch

url : www.url.com

----------------------

How can I make it look better?

Thanks
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41601
    
  55
What does this have to do with HTML/JavaScript (which this forum is all about)?


Ping & DNS - my free Android networking tools app
Sahana Hegde
Ranch Hand

Joined: Jan 27, 2008
Posts: 67
Well, I was not sure where to put it. Please let me know where I should post the same.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19680
    
  19

You could use HTML formatted email.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Sahana Hegde
Ranch Hand

Joined: Jan 27, 2008
Posts: 67
Thanks for the reply.
How do I create HTML formatted emails. Can you please suggest any link.
The first few links I found on google were not very helpful.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19680
    
  19

Use MimeMessage's setContent(Object, String) method. The first parameter will be a String with the HTML content, and the second will be "text/html".
 
wood burning stoves
 
subject: Generate Email body