HALLO alle,Pfundzeichen funktioniert nicht in Mail-Inhalt mit java.mail-Paket?
I javax.mail packaage MINEMESSAGE verwenden, MimeMultipart Klasse eine E-Mail zu senden, aber auch wenn ich schon erwähnt, Typen utf-8, Unicode-Zeichen funktionieren nicht im Fließtext. wie Pfundzeichen funktioniert nicht. bitte helfen, was zu tun ist. hier ist meine Nachrichten-Header ist
To: [email protected]
Message-ID: <[email protected]>
Subject: My Site Free Trial - 5 days left
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_Part_0_1733237863.1294898905008"
MyHeaderName: myHeaderValue
Date: Thu, 13 Jan 2011 06:08:25 +0000 (UTC)
------=_Part_0_1733237863.1294898905008
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
**Here Body message**
Take advantage of our best value price annual subscription at only= =EF=BF=BD=EF=BF=BD49 per month. Or our no commitment monthly subscription= at just =EF=BF=BD=EF=BF=BD59 per month. "
Actual out put should be: "Take advantage of our best value price annual subscription at only £49 per month. Or our no commitment monthly subscription at just £59 per month.
hier den Code
MimeMessage msg = new MimeMessage(session);
InternetAddress addressTo[] = new InternetAddress[emsg.getRecipeants()
.size()];
int i = 0;
try {
for (String email : emsg.getRecipeants()) {
InternetAddress address = new InternetAddress(email);
addressTo[i] = address;
log.info(acc.getSenderEmailID() + " sending mail To " + email);
}
msg.setRecipients(Message.RecipientType.TO, addressTo);
if (emsg.getReplayTO() != null) {
msg.setReplyTo(new InternetAddress[] { new InternetAddress(emsg
.getReplayTO()) });
}
String from = "";
if (!acc.getAccoutName().equals("")) {
from = acc.getAccoutName() + "<" + acc.getSenderEmailID() + ">";
} else {
from = acc.getSenderEmailID();
}
msg.setFrom(new InternetAddress(from));
// MultiPart body part
Multipart multipart = new MimeMultipart();
// This is the message body content part
MimeBodyPart messageContentPart = new MimeBodyPart();
String content = processContent(emsg.content, multipart,
comapanyDBName);
if (emsg.isPlain) {
messageContentPart.setContent(content,
"text/plain; charset=UTF-8");
} else {
messageContentPart.setContent(content,
"text/html; charset=UTF-8");
}
multipart.addBodyPart(messageContentPart);
// This is the template Attachment part
if (emsg.getAttachment() != null) {
for (File file : emsg.getAttachment()) {
MimeBodyPart messageAttachmentBodyPart = new MimeBodyPart();
messageAttachmentBodyPart = new MimeBodyPart();
DataSource source = new FileDataSource(file);
messageAttachmentBodyPart.setDataHandler(new DataHandler(
source));
messageAttachmentBodyPart.setFileName(file.getName());
multipart.addBodyPart(messageAttachmentBodyPart);
}
}
// Put parts in message
msg.setContent(multipart);
// end
// Optional : You can also set your custom headers in the Email
// if
// you
// Want
msg.addHeader("MyHeaderName", "myHeaderValue");
// Setting the Subject and Content Type
msg.setSubject(emsg.subject, "UTF-8");
// msg.setSubject(emsg.subject);//text/plain; charset=ISO-8859-1
// msg.setContent(map.getValue().getContent(), "text/html");
} catch (AddressException e) {
e.printStackTrace();
} catch (MessagingException e) {
e.printStackTrace();
}
return msg;
Was im Nachrichtentext ist? Erscheint das '£' wie '= C2 = A3? – dan04
Diese codierten Oktette sind die UTF-8-Repräsentation des "U-FFFD-ERSATZCHARAKTERS". Bitte zeigen Sie Ihren tatsächlichen Code, etwas stimmt nicht damit. –
Ich habe die meine Frage bearbeitet. bitte sehen Sie es sich an –