質問

被験者はちんぷんかんぷんな話として正しく身体が表示されますが表示されますが、

コードの下を使用して私は、英語以外で書かれた電子メールを送信することができます。
任意のアイデア?

ありがとう
public void postMail(String recipient, String subject, String message, String from) throws MessagingException, UnsupportedEncodingException {

            //Set the host smtp address
            Properties props = new Properties();
            props.put("mail.smtp.host", "mail.infodim.gr");

            // create some properties and get the default Session
            Session session = Session.getDefaultInstance(props, null);

            // create a message
            Message msg = new MimeMessage(session);

            // set the from and to address
            InternetAddress addressFrom = new InternetAddress(from);
            msg.setFrom(addressFrom);

            InternetAddress addressTo=new InternetAddress(recipient);
            msg.setRecipient(Message.RecipientType.TO, addressTo);

            // Setting the Subject and Content Type
            msg.setSubject(subject);

            msg.setContent(message, "text/plain");
            Transport.send(msg);

        }

正しい解決策はありません

他のヒント

試します:

msg.setContent(message, "text/plain; charset=UTF-8");

編集 text/plainに変更します。

の代わりに

msg.setContent(message, "text/plain");

私が書くでしょう。

Multipart mp = new MimeMultipart();
MimeBodyPart mbp = new MimeBodyPart();
mbp.setContent(message, "text/plain; charset=ISO-8859-7");
mp.addBodyPart(mbp);

msg.setContent(mp);

この文字セットは、ギリシャ語のためのものですので、私はあなたの名前からISO-8859-7を推測しますが、多分あなたはより多くのそれを正しく選択することができます。それとも、また、あなたのケースのためUTF-8作品ます。

何も他に助けていない場合は、UTF8へ(.javaファイルを含む)ソースファイルのエンコーディングを変更してみてください。 Eclipseで、それはウィンドウを介して行われる - >設定 - >一般 - >ワークスペース:テキストファイルのエンコーディング 私は、テキストファイルのデフォルトとしてCP1252を持っています。

私は、.propertiesファイルから私のテキストを取得しています。 UTF8にそれらを変更することは助けにはなりませんでした。 これは非常識ですが、UTF8に私の.javaファイルを切り替えるには、私の問題を解決!

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top