code to send email is following:
MimeMessage msg = new MimeMessage(session);
msg.setSubject("subject", "UTF-8"); // here you specify your subject encoding
msg.setContent("yourBody", "text/plain; charset=utf-8");
msg.setFrom("senderAddress");
msg.addRecipient(Message.RecipientType.TO, new InternetAddress(address));
Transport.send(msg);
My probelem is that as as i have encoded subject in utf-8 how can i encode recipient address ie. new InternetAddress(address)
Email address should follow RFC822 standard
JavaMail's MimeMessage uses InternetAddress:
RFC822 format says:
Personal names for address supports different charsets
InternetAddress uses a personal name:
To set charset for encoding, there is a InternetAddress#constructor. Looking at sources:
it just calls setPersonal(..), thus choose the way which is the most convenient for you.
To lookup a charset, use Charset.forName().