I'm able to create a .eml file with javax.mail library, but if the body is longer than 76 characters it's broken in more lines. The problem is than opening the .eml file with Windows Live Mail the '=' char appears in the email body in the corrispondence of the 76 character and the text is on multiline.
Could anyone help me please? Thank you
-Antonio
This is the .eml example file:
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--
and this is my current code:
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();
When I open the eml file, the message is:
The Stratford Bust, located on the wall of the chancel of Holy Trinity Chur=h at Stratford-upon-Avon, is the oldest and, along with the Droeshout Port=ait, most credible of all the known images of Shakespeare. But there are m=ny representations of the Bard that have been handed down throughout the c=nturies, each with its own fascinating story to tell.. Responsabilità= Generica
What I have to set in order to obtain the exact body? thanks
Sounds like you have not supplied the correct headers. If the body part is in QP you need a Content-Transfer-Encoding: quoted-printable
body part header to instruct the client.
If you need more help, the source of a problematic message would be useful for diagnostics. A correct minimal multipart message looks something like this:
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--
(Strictly speaking Date:
and Message-Id:
are mandatory, too, but the MTA will usually add them if they are missing.)