1

In one of my Java applications I have to forward e-mails. So, I get e-mails (plain text or multipart) with any content (maybe also attachments). I edit their subject, from- and to-header and send them via SMTP.

I already implemented this using Apache James Mime4j and Apache Commons Net but now I also have to append a footer/signature to the content of each e-mail.

Can I achieve this with Mime4j too? Would be great! How? If not: is there another way?


EDIT: Details after Wolfgang Fahl's comment:

Maybe I'm using the library the wrong way, but I am parsing the message as follows:

MessageBuilder messageBuilder = new DefaultMessageBuilder();
InputStream in = ...
Message m = messageBuilder.parseMessage(in);

Now I have an instance of Message and I can set it's subject, sender, etc. But Message does not provide a method setText() or something like that. Ok, there is getBody() but then I don't know how to manipulate the Body.

Ethan Leroy
  • 15,804
  • 9
  • 41
  • 63
  • Usually a footer is just part of the text of the message. So setText() would be your function. I assume you'd like to do something different - please explain what you are up to - may be with a code example. – Wolfgang Fahl Dec 03 '14 at 10:49
  • Thanks for trying to help me. I edited my question and added some details about my code. Basically I don't know what `setText()` method you mean. – Ethan Leroy Dec 03 '14 at 23:45
  • I see what's going on. Personally I do not use James methods for sending mail by SMTP. I use javax.mail.Message. See e.g. http://stackoverflow.com/questions/13358453/sending-an-mail-in-java-using-smtp for how to use it. You'll need to adapt from the james message to java's standard way on how to do things if you try this route. – Wolfgang Fahl Dec 04 '14 at 08:22

0 Answers0