• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Mail: Please help: Can I create a new Message with InputStream (binary/character  RSS feed

Ulrich Heeger
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,
I would to copy one message to another by replacing certain content of the mail.
I have for example one mail with attachments, containing both binary and character datas.
I would like to replace certain words in the body text (html) of the mail matching a pattern, before creating a new Message and copying the content of the old message to the new.
The html content and the parts should be preserved, so that images within the html-text should remain referenced.
First I iterated through the parts to get the body part which contains the html to replace the concerning words and to copy the parts to new ones. But the reference of the image tag to one attachment were not valuable any more.
So I had the idea to get the InputStream of the message:

But now I don't know how to get the InputStream in the new message. When I create a new MimeMessage(session, in) and I will send this message, the recipient will see the whole content as body content without any parts.
Does anybody have an idea?I would be very thankful for help.

Regards, Ulrich
[ August 29, 2005: Message edited by: Ulrich Heeger ]
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!