Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Javamail - how to mix static and dynamic plain text content?

John Boyes
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to use javamail to send plain text messages. No messages will have attachments or be in html format. The content of a message is a mixture of static text and dynamic content. I would like to keep the static content in a text file, and read it in.
My problem is the best way to read the content such that I can:
1) replace designated placeholders in the static content with the dynamic content.
2) pass the content as a String to the MimeMessage class's setText method.
Should I just use standard classes (e.g. InputStream), or should I use the Java Activation Framework for instance?
Also, this approach will see the contents of my text file to a (very long) String - will I lose the text formatting?
One way I have explored is to make the message multipart, but this seems to be the wrong approach as the message is to be plain text (therefore multipart is a misleading and inaccurate header for the email).
Any help/ideas much appreciated.
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic