Sending a letter using javax.mail.* . I configure the content using an object of type MimeMessage as follows

 generateMailMessage.setContent(emailBody, "text/html"); 

in which emailBody is an object of type String containing the text of the letter, including Cyrillic. But the letter comes as follows: ??????? ??????? ????? ???????! text messag (3.0?) ????? ????: BIA-5083? R, that is, all Cyrillic characters and some others (such as -) are replaced with question marks.

A quick search found a solution to the problem using the method

 generateMailMessage.setText(emailBody, ENCODING); 

where String ENCODING = "koi8-r"; , but in such a letter it is impossible to configure html lines, which is sad.

Is it possible to correctly send a letter containing html tags (which will be displayed correctly) and Cyrillic?

    1 answer 1

    1. Your project should be utf-8 and run utf-8. Other encodings do not exist.

    2. Your generateMailMessage should be MimeMessage . Then we generateMailMessage.setContent(emailBody, "text/html; charset=utf-8");

    • Well, I wrote that the generateMailMessage object is of type MimeMessage. But nevertheless, adding to the type string "text / html; charset = utf-8" everything worked! Thank you so much - abbath0767