• Post Reply Bookmark Topic Watch Topic
  • New Topic

Formatting Email Content - Beginner  RSS feed

 
Crystal Bazil
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to format email content and I am having a really rough time trying to figure this out.

First, I have a LinkedHashMap whose key is my list title and the value is an ArrayList of my list items. I would like to be able to format this email content like so:

List Title
List item
List item
List item

The below code prints out exactly what I need but I think there should be a way for me to combine the two. I just havent been able to find out how to do it.

For example:

Secondly, I have followed an example in a book on how to send an email. I have this working but I am unsure how to set my content string to the above code. In the book, the content was very easy to set.

Example:


However, how would I be able to set content to something more complex like the above code? I realize this is a silly question but any help would be greatly appreciated. Thanks in advance!

Crystal
[ May 22, 2006: Message edited by: Crystal Bazil ]
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you can do the loops you have but replace System.out.println() with building up a content string. This is typical:

You could do this with just String (content = content + line "\sb") but StringBuffer is more efficient and common practice.

I'm not sure about mail software ... if it seems to ignore the newlines you might look into sending HTML?
 
Crystal Bazil
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stan - Thank you for your advice. The solution worked perfectly! I had to append HTML to get line breaks but other then that perfect!

Thanks once again,
Crystal
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!