【问题标题】:Runnable JAR bad Encoding in hebrew希伯来语中可运行的 JAR 错误编码
【发布时间】:2014-09-16 11:24:14
【问题描述】:

标签: java eclipse encoding executable-jar right-to-left


【解决方案1】:

终于搞定了,

使用了这个代码:

// -- Create a new message --
final MimeMessage msg = new MimeMessage(session);

// -- Set the FROM and TO fields --
msg.setFrom(new InternetAddress(username));
msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(recipientEmail, false));

if (ccEmail.length() > 0) {
msg.setRecipients(Message.RecipientType.CC, InternetAddress.parse(ccEmail, false));
}

msg.setSubject(title, "utf-8");
msg.setText(message, "utf-8");
msg.setHeader("Content-Type", "text/html; charset=UTF-8");
msg.setSentDate(new Date());

MimeBodyPart mbp1 = new MimeBodyPart();
  try {
mbp1.setDataHandler(new DataHandler(
new ByteArrayDataSource(message.toString(), "text/html")));
      } catch (IOException e1) {
     e1.printStackTrace();
  }
 mbp1.setHeader("Content-Type","text/plain; charset=\"utf-8\""); 
 mbp1.setContent( message, "text/html; charset=utf-8" ); 
 mbp1.setHeader("Content-Transfer-Encoding", "quoted-printable");

// create the second message part
MimeBodyPart mbp2 = new MimeBodyPart();

// attach the file to the message
try {
mbp2.attachFile(fileName);
    } catch (IOException e) {
   e.printStackTrace();
}

Multipart mp = new MimeMultipart();
mp.addBodyPart(mbp1);
mp.addBodyPart(mbp2);
msg.setContent(mp, "text/html");

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-07-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-09
    • 2012-01-30
    相关资源
    最近更新 更多