• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 java.io 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.
John
 
reply
    Bookmark Topic Watch Topic
  • New Topic