MimeMessage身体长76个字符

时间:2013-04-13 12:51:42

标签: java mime javax.mail

我可以使用javax.mail库创建一个.eml文件,但是如果正文长度超过76个字符,那么它会在更多行中被破坏。 问题不仅仅是在Windows Live Mail中打开.eml文件,在76字符的相应性中,电子邮件正文中出现'='字符,文本在多行上。

有人可以帮我吗? 谢谢

-Antonio

这是.eml示例文件:

X-Unsent: 1
Message-ID: <2037894577.5.1365866504487.JavaMail.Nunziante@Nunziante-TOSH>
Subject: Comunicazione Contenzioso Spedizione 8092255513 del 09-04-2013
MIME-Version: 1.0
Content-Type: multipart/mixed; 
boundary="----=_Part_4_1091659763.1365866499167"

------=_Part_4_1091659763.1365866499167
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

The Stratford Bust, located on the wall of the chancel of Holy Trinity Chur=
ch at Stratford-upon-Avon, is the oldest and, along with the Droeshout Port=
rait, most credible of all the known images of Shakespeare. But there are m=
any representations of the Bard that have been handed down throughout the c=
enturies, each with its own fascinating story to tell.. Responsabilit=C3=A0=
: Generica


------=_Part_4_1091659763.1365866499167--

这是我目前的代码:

Message message = new MimeMessage(javax.mail.Session.getInstance(System.getProperties()));
message.setFrom(new InternetAddress(from));
message.setRecipients(Message.RecipientType.TO, getAddress(to));
message.setSubject(subject);
Multipart multipart = new MimeMultipart();
MimeBodyPart content = new MimeBodyPart();
multipart.addBodyPart(content);
content.setText(body);
message.setContent(multipart);
FileOutputStream fos = new FileOutputStream(emlFile);
message.writeTo(fos);
fos.close();

当我打开eml文件时,消息是:

斯特拉特福胸围,位于埃文河畔斯特拉特福的圣三一教堂的墙上,是最古老的,与Droeshout Port = ait一起,是所有已知的莎士比亚形象中最可信的。但是,在整个世界各地都有传说中的巴德的代表,每个代表都有自己的迷人故事.Responsabilità= Generica

我必须设置什么才能获得确切的身体? 感谢

1 个答案:

答案 0 :(得分:0)

听起来你没有提供正确的标题。如果身体部位在QP中,则需要Content-Transfer-Encoding: quoted-printable身体部位标题来指示客户。

如果您需要更多帮助,有问题的消息来源对诊断非常有用。正确的最小多部分消息如下所示:

From: me@example.net
To: you@site.example.co
Subject: privet, mir
Mime-Version: 1.0
Content-type: multipart/mixed; boundary=foo

--foo
Content-type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Hello w=
orld.

--foo--

(严格来说Date:Message-Id:也是强制性的,但如果丢失,MTA通常会添加它们。)