[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[iaik-jce] Special char. encoding



Hello,

Here is my problem

I have written Java classes in order to send signed and/or
encrypted mails.

If the mail contains as attachment a file of which the
name (or the path) contains a special character like 'é',
the mail is not correctly built.

The part relative to the attachment looks like this:
...
Content-Type: application/octet-stream; name = "Comélux"
Content-transfer-Encoding = base64
Content-disposition : attachment; filename="Comélux"
...


I want these parameters to be encoded like this:
...
Content-Type: application/octet-stream; name = "Com=E9lux"
Content-transfer-Encoding = base64
Content-disposition : attachment; filename="Com=E9lux"
...

You can find below the code used to build the mail.

...
//       Builds a mutilpart Mime
         MimeBodyPart mbp1 = new MimeBodyPart();
         mbp1.setText(msgText);

         Multipart mp = new SMimeMultipart();
         mp.addBodyPart(mbp1);

         for (i=0; i<attachedFilePath.length; i++) {
              MimeBodyPart attachment = new MimeBodyPart();
              if (attachedFilePath[i] != null) {
                  FileDataSource attachmentFds = new
FileDataSource(attachedFilePath[i]);
                  DataHandler dtH = new DataHandler(attachmentFds);
                  attachment.setDataHandler(dtH);
                  attachment.setFileName(attachedFilePath[i]);
                  mp.addBodyPart(attachment);
              }
         }
...

I think that the problem is located at this line:
   attachment.setFileName(attachedFilePath[i]);

I  probably should encode 'attachedFilePath[i]' in a
other manner. Could you tell me how ?

Thanks,


Benoît.


--
**********************************************************

   Otjacques Benoît

   CRP-Gabriel Lippmann
   Cellule de Recherche, d'Etude et de Développement en Informatique
   162a, Av. de la Faïencerie
   L-1511 Luxembourg.

   Tel. +352-47.02.61-373.
   Fax  +352-47.02.64.

   "Il n'a y pas de vent favorable
    pour celui qui ne sait pas où il va."
    Sénèque.

**********************************************************


--
Mailinglist-archive at http://jcewww.iaik.tu-graz.ac.at/mailarchive/iaik-jce/maillist.html

To unsubscribe send an email to listserv@iaik.tu-graz.ac.at with the folowing content: UNSUBSCRIBE iaik-jce