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 formatting problem

Steven Hunter
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a program that scans an inbox. If a message has an attachment then the attachment is saved to the local filesystem. If the message does not have an attachment, then it is assumed that the data is in the body of the email. This text is extracted and saved as a file to the local filesystem.
The problem is this, formatting is preseved in the saved attachment, but not in the saved body text. The sent emails contain fixed size field data e.g. Oracle sql loader style data and therefore all spaces and carriage returns MUST be preserved. Currently the saved output is removing spaces and adding carriage returns to the point that the saved file is almost half the size of the original body text.
The java source uses the folowing to get the body text:
Object content = message[i].getContent();
strMessageBody = content.toString();
Since the context type is text/plain then a String is all I can get the message back as.
What can I do to preserve formatting?
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic