1

I have a service, which gets a java.io.InputStream and the datas from it to build a mime massage and send it with the help of a SMTPServer to the given address. The problem is, that the char encoding of the incoming emails is bad, it cannot send the following UTF8 chars (e.g.: ÖÜß), but just in the subject, the message buddy is ok.

The code as follows where the datas come in:

public void data(InputStream data) throws IOException { 
    Session s = Session.getDefaultInstance(new Properties());
    try {
    System.setProperty("mail.mime.charset", "UTF8");
    MimeMessage m = new MimeMessage(s, data);
                        .
                        .

The question is, how can I check the encoding of the datas, which are coming in from this InputStream? I would like to know, that the datas are already corrupted (wrong encoding) when this service gets them from an other app, or the problem is in the code of this service where this mime message will be later on manipulated.

I know that the InputStreamReader has a method "getEncoding()", but in this code there is no InpuStreamREader, just InputStream Some other infos: I already set the default file encoding. Default the mime message encoding will be set from the default system encoding. After that I set the "mime.mail.charset" as a Systemproperty and also in the spring bean definition. On the other hand I tried the set the subject with the overloaded version of the mimemessage.setSubject(String subject, Encoding e). On the other hand I use a JavaMailSenderImpl, where I also set the encoding (mailSender.setDefaultEncoding("UTF8");). I tried everything, what I found as a possibility, but nothing helped. Thanks for helping me in advance!

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Peter
  • 11
  • 1

0 Answers0