Java Mail API - Encoding problems

前端 未结 9 1311
野趣味
野趣味 2020-12-31 11:14

I\'m using Java Mail API and I\'m trying to send an email through Gmail\'s SMTP. How my program works: java.util.Scanner class is used to get user input - I\'m asking user f

相关标签:
9条回答
  • 2020-12-31 11:48

    In case if you use HTML messages, try this:

    Message message = new MimeMessage(session);
    message.setContent(htmlText, "text/html; charset=UTF-8");
    
    0 讨论(0)
  • 2020-12-31 11:48

    the following charset working to me: charset=ISO-8859-1, example:

    mail.setContent(testMail.getTexto(), "text/plain; charset=ISO-8859-1");
    
    0 讨论(0)
  • 2020-12-31 11:49

    Use the encodeText method from MimeUtility:

    MimeUtility.encodeText(mail_subject, "UTF-8", "B")
    

    (I don't know what "B" means, keep calm, and just use. Actually it can be "B" or "Q".)

    0 讨论(0)
提交回复
热议问题