Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MimeMessage and accentuated character for attachment

Status
Not open for further replies.

Izzac

Programmer
Jan 26, 2001
20
CA
Hi
I send mail with javax.mail.internet.MimeMessage. My attachment is a PDF. I receive my mail and my PDF is perfect, but when the name of my PDF file contains accentuated characters(é è à ç...) these ones disappear.

ex : Stéphane.pdf ---> Stphane.pdf

I don't know well the rules of encoding and even less for the email.

anybody have an idea ?

code :

MimeMessage message = createMessage(fromAddress,
replyTo, to, cc, bcc, subject);

MimeMultipart mp = new MimeMultipart();
MimeBodyPart attachPart = new MimeBodyPart();
String attachmentFileName = null;

attachPart.setFileName(attachment.getName());
RSBytesArrayDataSource ds = new RSBytesArrayDataSource(attachment.getBinaryBody(), attachment.getContentType().getMimeType());
DataHandler dh = new DataHandler(ds);
attachPart.setDataHandler(dh);
mp.addBodyPart(attachPart);

message.setContent(mp);
message.saveChanges();
 
I forgot. The header of mail is :

Message-ID: <123123.JavaMail.jboucher@jboucher>
Date: Thu, 5 Feb 2004 15:55:45 -0500 (EST)
From: &quot;14181238899@123.com&quot; <faxback@123123.com>
Reply-To: faxback@123123.com
To: jboucher@123123.com
Subject: =?iso-8859-1?Q?Carrier,_St=E9phane_hmw?=
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary=123123.123123.JavaMail.jboucher.jboucher
Return-Path: faxback@123123.com
X-OriginalArrivalTime: 05 Feb 2004 20:55:50.0324 (UTC) FILETIME=[6FB23F40:01C3EC2A]

--123123.123123.JavaMail.jboucher.jboucher
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

--123123.123123.JavaMail.jboucher.jboucher
Content-Type: application/pdf; name=&quot;canmchinese éèàïê canmchinese çîêâû (5105).pdf&quot;
Content-Disposition: attachment; filename=&quot;canmchinese éèàïê canmchinese çîêâû (5105).pdf&quot;
Content-Transfer-Encoding: base64
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top