Can't get the attachment filename out of a Part (with non ascii characters)

Hello, all and happy new year :)
My issue is with non ascii filename in attachments... Yes i've read the FAQ : http://www.oracle.com/technetwork/java/faq-135477.html#encodefilename
I can't get the filename out of the BodyPart for those kind of attachments
here's my unit test :
     * contains various parts from various mailer encoded in different ways...
     private enum EncodedFileNamePart{
          OUTLOOK("Content-Type: text/plain;\n name=\"=?iso-8859-1?Q?c'estd=E9j=E0no=EBl=E7ac'estcool.txt?=\" \nContent-Transfer-Encoding: 7bit\nContent-Disposition: attachment;\n filename=\"=?iso-8859-1?Q?c'estd=E9j=E0no=EBl=E7ac'estcool.txt?=\" \n\nnoel 2010\n","c'estdéjànoëlçac'estcool.txt"),
          GMAIL("Content-Type: text/plain; charset=US-ASCII; name=\"=?ISO-8859-1?B?ZOlq4G5v62znYWNlc3Rjb29sLnR4dA==?=\"\nContent-Disposition: attachment; filename=\"=?ISO-8859-1?B?ZOlq4G5v62znYWNlc3Rjb29sLnR4dA==?=\"\nContent-Transfer-Encoding: base64\nX-Attachment-Id: f_giityr5r0\n\namluZ2xlIGJlbGxzIQo=\n","déjànoëlçacestcool.txt"),
          THUNDERBIRD("Content-Type: text/plain;\n name=\"=?ISO-8859-1?Q?d=E9j=E0no=EBl=E7acestcool=2Etxt?=\"\nContent-Transfer-Encoding: 7bit\nContent-Disposition: attachment;\n filename*0*=ISO-8859-1''%64%E9%6A%E0%6E%6F%EB%6C%E7%61%63%65%73%74%63%6F;\n filename*1*=%6F%6C%2E%74%78%74\n\njingle bells!\n","déjànoëlçacestcool.txt"),
          EVOLUTION("Content-Disposition: attachment; filename*=ISO-8859-1''d%E9j%E0no%EBl.txt\nContent-Type: text/plain; name*=ISO-8859-1''d%E9j%E0no%EBl.txt; charset=\"UTF-8\" \nContent-Transfer-Encoding: 7bit\n\njingle bells\n","déjànoël.txt"),
          String content=null;
          String target=null;
          private EncodedFileNamePart(String content,String target){
               this.content=content;
               this.target=target;
          public Part get(){
               try{
               ByteArrayInputStream bis = new ByteArrayInputStream(this.content.getBytes());
               Part part = new MimeBodyPart(bis);
               bis.close();
               return part;
               catch(Throwable e){
                    return null;
          public String getTarget(){
               return this.target;
     @Test
     public void testJavamailDecode() throws MessagingException, UnsupportedEncodingException{
          System.setProperty("mail.mime.encodefilename", "true");
          System.setProperty("mail.mime.decodefilename", "true");
          for(EncodedFileNamePart part : EncodedFileNamePart.values())
               assertEquals(part.name(),MimeUtility.decodeText(part.get().getFileName()),part.getTarget());     
I take a NullPointerExcepion in the decodeText because getFileName() return null for the EVOLUTION case, and work well with OUTLOOK, THUNDERBIRD and GMAIL.
Evolution's content type is "Content-Disposition: attachment; filename*=ISO-8859-1''d%E9j%E0no%EBl.txt" wich doesn't look like the other (looks like the RFC 2616 or RFC5987 to do it.)
How can i handle this situation except by writting my own decoder?
Thanks for your answers!
Edited by: user13619058 on 4 janv. 2011 07:44

Set the System property "mail.mime.decodeparameters" to "true" to enable the RFC 2231 support.
See the javadocs for the javax.mail.internet package for the list of properties.
Yes, the FAQ entry should contain those details as well.

Similar Messages

  • Oj4632 I can't get the paper device out of my new printer? locked in somehow.

    oj4632 I can't get the paper device out of my new printer? locked in somehow. very frustratied

    Set the System property "mail.mime.decodeparameters" to "true" to enable the RFC 2231 support.
    See the javadocs for the javax.mail.internet package for the list of properties.
    Yes, the FAQ entry should contain those details as well.

  • I recently bought a new macbook pro and set it up using the migration assistant and my mac mini.  I can't get the text message forwarding feature to work with both computers.

    I recently bought a new macbook pro and set it up using the migration assistant from my mac mini.  I can't get the text message forwarding feature to work with both computers.  It keeps saying that I only have 2 devices setup, my iPad and my macbook pro.  When I mess with the setting on my mac mini, it goes from saying that that is one of the devices to my macbook pro being the 2nd device.  I think that something happened as a result of my using the migration assistant and now it thinks that my macbook pro and my mac mini are one and the same computer.  Any ideas?

    Thanks, Sig.
    The old computer is a 2.6 Ghz Intel Core 2 Duo
    The new one is a 2.3 GHz intel core i7
    In going over this, thanks to "tallking it out" with you, I did discover the Text Edit problem.  Because I've still been unable to get the new computer text size (fonts or whatever) to match the old computer, I did not notice that the curser is now different--the line midway down the curser has to be placed on the line I am working upon, otherwise the edits go elsewhere on the page.  Now, with a bit of difficulty, I am able to get Text Edit to work correctly.
    If you have any ideas as to why my menu bar and Text Edit type are still so slow, I'd love to have them. 
    (I went through the process you suggested earlier, re my Trackpad preferences, and found no improvement.)

  • I bought the Mac version of Premiere Elements, can I get the Windows version for free or cheap with my serial number?

    I bought the Mac version of Premiere Elements, can I get the Windows version for free or cheap with my serial number? I'm about to migrate back to PC soon and I'd love to not have to buy the program again since I just bought it. Under my order history though it only shows it for Mac so I wanted to make sure.

    ihavea4
    The boxed packaging is not sold by Adobe direct. If you want to explore that type of purchase which offers the perk of a Windows and a Mac installation disc, you need to purchase from an authorized reseller who is not going to offer you "upgraded pricing". The seller would be its own entity with its own pricing and own return/refund policy. Sometimes the authorized reseller price may be less than the Adobe"upgraded pricing".
    Did you purchase your Premiere Elements 13 Mac from Adobe direct and are within 30 days of purchase? If so, you can contact Adobe Chat Orders to ask for return/refund. And, then you can explore the authorized resellers for pricing and availability of the box packaging. Maybe check out the pricing all around before making any final decisions.
    Please review and consider.
    Thank you.
    ATR

  • I can not get the flash player plug in to work with Internet Explorer

    I can not get the flash player plug in to work with Internet Explorer

    Zoltan71 wrote:
    I just bought this computer. My Internet Explorer is version 11.0.1
    I have the box checked to Install new version automatically, but it has not done any upgrading.
    I can't get the computer to update anything as far as I can see.
    The flash plug in does work with the Crome browser but it will not work with Internet explorer.
    I looked in the manage add-ons and it says enabled.
    I also went into the safety tab and deselected
    Active X filtering.
    Restarted and still does not work.
    I need help.....
    Chrome uses a different and separate plug-in.
    There are things about IE you need to know, especially 11. Specifically:
    "User-Agent Strings"
    That doesn't mean a lot, I'm sure, but it's the root of your problems, and Flash Player has nothing to do with it.
    Microsoft "rewrote" the User-Agent Strings for the abomination they call their latest and greatest browser. User-Agent Strings are what websites use to identify the browser you're using and provide the proper content for it's browser engine, like ActiveX stuff, and Flash or HTML5 video. Thanks to the geniuses in Redmond, WA, the User-Agent Strings for IE11 (which has a Trident engine), ID it as either "Gecko" (Firefox) or "Webkit" (Chrome). Problem is: when the site the directs to the content for one of these two engines, the Trident engine in IE can't intepret it and the site then sees IE as an "unidentified" browser.
    The problem with an unidentified browser is that the plug-ins in that browser aren't recognized either, so even though you're up to date, it says you need the latest Flash Player when you use IE11. YouTube... has converted to HTML5 video so if it doesn't detect Flash Player, it can display HTML5 (MP4) video which requires no plug-in to play. Facebook can't do that, because HTML5 doesn't apply to games... only video.
    Microsoft has no plans to "fix" the mess they've created because they think it's a great idea to block you out of the websites you visit.
    They recommend using "Compatibility View" and pretending that you're using an older verison of IE... Problem with that is that it's seen limited success, and you have to enable it for EVERY page that has problems... individually.
    I'm not big on "pretending" so I recommend actually using another browser.
    Firefox (from Mozilla)
    Opera (from Opera)
    Safari (from Apple)
    Chrome (from Google)
    ANY of those will work where IE11 won't, with the Flash Player Plug-in (For all other browsers), and Chrome doesn't even need that because it has its own Flash Player plugin built in.

  • How can I get the phone numbers in contacts to appear with dashes between the first 3 numbers, the next 3 numbers, and the last 4 numbers?  Until very recently it did so.  Contacts on my macbook pro does show up this way.  I do have a mobile me account an

    How can I get the phone numbers in contacts to appear with dashes between the first 3 numbers, the next 3 numbers, and the last 4 numbers?  Until very recently
    it did so.  Contacts on my macbook pro does show up this way.  I do have a mobile me account and in the past syncing was no problem.  What setting has changed?

    The phone number format as well as the date language and format and the time format are controlled by the Region Format setting. Go to Settings > General >International > Region Format.  When you change a region format, you can go back one page (to International) and see an example of the date/time/phone number format that your selected region format will produce.

  • How can you get the schedule of a single reoccurring job with Restart ability in Redwood to pause when it has failed...?

    We need the Request Restart ability when scheduling a single reoccurring job in Redwood. Most of our jobs are scheduled in CHAINs which offers the Final Status Handler on Step level, and the schedule is "paused" when a job in the CHAIN has failed ( the next instance does not populate until the OP MSG has been Replied to) , and once the OPERATOR message is replied to, the CHAIN can resume running again ( desired ) . But we need this same ability when scheduling a single job not in a CHAIN. In our testing, we set up a job with Request Restart chosen on the Error , Killed and Unknown selections on the Restart Behavior Tab. But we found when a job is scheduled say once a day at 8AM, and when it fails, an OPERATOR msg appears allowing a Restart choice ( desired), but the next day's schedule also populates ( undesired) and we do NOT want the schedule to continue on yet because we need a chance to fix the error before the next insance runs for business reasons. So how can you get the schedule of a single reoccurring job with Restart ability in Redwood to pause when it has failed...?

    Hello Fran,
    You can wrap the job chain in a master job chain in the first step and set the final status handler there.
    You can also set the Restart Behavior to 'Stop Submit Frame', in that case you will have to resubmit the job once you are finished troubleshooting.
    Regards Gerben

  • Can only get the "Draft" stamp when insert customer stamp with C#+JS

    I am trying to insert customer stamp in batch files with C#+JS.
    My JS works well in Acrobat. However, it doesn't work when use C#+JS. I always get the Acrobat's "Draft" stamp other than my own ones (the AP value is confirmed correct).
    In c#, it runs as this ( with the objectype.InvokeMember())
    1. initial an annotation with addAnnot first and get the properties object with method of getProp().
    2. Set the type entry of the properties object as "Stamp"
    3. With setProp(), modify the annotation to a Stamp annotation, and then get the properties object of the Stamp annotation.
    4. Set the entries (rect, page, AP ) of the properties object. Then use setProp() again to modify the properties of the Stamp annotation.
    The program runs without any error message. But I can only get the default stamp "Draft".
    One thing I found so far, in JS console in Acrobat, if I set the AP properties AFTER set the annotation type to "Stamp", it also get the "Draft" stamp only. as this,
         annot = this.addAnnot();
         prop = annot.getProps();
         prop.type = "Stamp";
         annot.setProps(prop);
         prop = annot.getProps();
         prop.page = 0;
         prop.rect = [0, 0, 100, 100];
         prop.AP = "#xxxxxxxx";
         annot.setProps(prop);
    If I set the prop.Ap before the forth line in above para, I can get the right stamp.
         annot = this.addAnnot();
         prop = annot.getProps();
         prop.type = "Stamp";
         prop.AP = "#xxxxxxxx";
         annot.setProps(prop);
         prop = annot.getProps();
         prop.page = 0;
         prop.rect = [0, 0, 100, 100];
         annot.setProps(prop);
    Or, if I set the props in the typcial JS format like below, I also get the right one
    annot = this.addAnnot({
    type: stamp,
    page: 0,
    rect: [0,0,100,100]
    AP: #xxxxxxxx)});
    But, the problem is, in C#, the AP properties can only be set after set the annotation type as Stamp (step 4). I think this might be the reason, but I don't know how to get over this.
    Please help. Thanks!

    No, it can't – but you could do that yourself as part of the watermarking process (ie. Two watermarks or fields)
    From: santa-satan <[email protected]<mailto:[email protected]>>
    Reply-To: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>>
    Date: Mon, 6 Feb 2012 18:35:19 -0800
    To: Leonard Rosenthol <[email protected]<mailto:[email protected]>>
    Subject: Can only get the "Draft" stamp when insert customer stamp with C#+JS
    Re: Can only get the "Draft" stamp when insert customer stamp with C#+JS
    created by santa-satan<http://forums.adobe.com/people/santa-satan> in Acrobat SDK - View the full discussion<http://forums.adobe.com/message/4190155#4190155

  • HT4112 I can not get the 2003 Bluetooth wireless keyboard to pair with my ipad.  How do I do this?  According to the information above, this IS possible...

    I can not get the 2003 Bluetooth wireless keyboard to pair with my ipad mini, 32gb wifi.  How do I do this?  According to the information above, this IS possible...

    Never mind...  Didn't see the "not compatible"...  Stupid...  It's bluetooth.  Bluetooth apple should connect to bluetooth apple...  Period...

  • How can I get the code to synchronize my Iphone 5 with my Itunes?

    how can I get the code to synchronize my Iphone 5 with Itunes?

    By code, I think you are referring to the code on your iPhone.  To sync for the 1st time with iTunes you'll need to enter the code on your iPhone to unlock it.  Typically if your phone is unlocked and then connected to your computer, it will lock itself.  Just reenter the code.  Then you should get another prompt on your iPhone to "trust" your computer so you can sync with it.

  • I can not get the right frequency out of my NI-DAQ 6062E card from Matlab

    Hi.
    My name is Johan and I want to generate an analog square waveform with 5.76 kb/s in frequency with my NI DAQCard-6062E from Matlab.
    When I run in Matlab the program below, I get the frequency of 5.747 kb/s on the output channel (even thou I have chosen 5.76 kb/s). When I try to change the sample rate, to higher values in Matlab, I get the same frequency until I choose the sample rate to 5.79 kb/s. The output signal is in that case is 5.813 kb/s.
    So my problem is that I can't get the exact frequency of 5.76 kb/s.
    How do I solve this.
    Thankful for help.
    Best regards, Johan
    Program in Matlab:
    clear all
    openDAQ=daqfind; %Detect any open DAQ channels
    for i=1:length(openDAQ), %Close any open DAQ channels
      stop(openDAQ(i));
    end
    ao = analogoutput('nidaq',1); %Create an object for analog output
    addchannel(ao, [0 1]);
    set(ao, 'SampleRate', 2*5760); %Here the sample rate is specied. 2*, because to get right samplerate
    y=[80,-80] %Sets theoutput values to 80 and -80 (As -1 and 1)
    putdata(ao, [y' y']); %Sends the values to out buffer
    set(ao,'RepeatOutput',inf) %Repeats sending in infinity
    set(ao, 'TriggerType', 'Immediate'); %Choose trigger to immediate, because sending values shall occur driect after start command.
    start(ao);
    %stop(ao)

    Hello Johan!
    Bad news I am afraid….
    I assume you are using the Data Acquisition Toolbox from the Mathworks and when it comes to support on that interface I have to advice you to contact the Mathworks for assistance. We don't provide any support on their data acquisition interface since we have nothing to do with it.
    Sorry for the inconvenience this might cause you.
    Regards,
    Jimmie A.
    Applications Engineer, National Instruments
    Regards,
    Jimmie Adolph
    Systems Engineer Manager, National Instruments Northern Region
    Bring Me The Horizon - Sempiternal

  • I can't get the old account out my update

    I can not get the old account off even if I sign in on my new account the old still show up and I can't update how do I get the old one out my iPad I tried signing out and in, my new account is in but when I try to update something an old account pops up and I can't do anything

    Settings > iTunes and App Store > Apple ID = Sign Out... Then Sign In using the preferred Apple ID.
    Dinky710 wrote:
    ... but when I try to update something an old account pops up ...
    Anything Downloaded with a Particular Apple ID is tied to that Apple ID and Cannot be Merged or Transferred to a Different Apple ID

  • How can I get the third battery out of the wireless keyboard to change it?

    I got a message to change the batteries in my keyboard, but only two batteries will come out.  Is there a way to get the third one out?

    turn your keyboard over-there should be a diagram telling you how many batteries
    it takes (2 or 3). If you do have a 3 battery keyboard, perhaps a little wiggling or tapping may help, or a little wd-40, maybe a chopstick?
    JB

  • Cannot rename file with non-ASCII characters when using the

    My application moves files from one directory to another by calling File[] srcFiles = srcDir.listFiles() to get a list of files in the source directory, and then calling srcFiles.renameTo(destFile) to rename each file.
    This does not work (renameTo returns false and the file is not moved) under the following circumstances:
    - the file's leaf name contains non-ASCII characters, for example "�"
    - the OS is Solaris 9
    - the LANG and LC_* environment variables are unset, i.e. the C locale is being used
    If I set the LANG environment variable to, for example, en_GB.UTF-8 then the rename succeeds.
    I have tried calling srcFiles[index].getName().getBytes("UTF-8") and the non-ASCII characters are being replaced with ? (0x3f) characters when LANG is unset.
    Is this a bug in the JRE? I would argue that since my code does not actually manipulate the filename (I just use the File object that File.listFiles() gives me) then the rename should succeed. Of course I would not expect the file name to be displayed correctly if I printed it out.
    I have reproduced this behaviour with JDK 1.4.2_05 and 1.5.0_04 on Solaris 9.
    Francis

    Thanks for the info Alan.
    I considered setting the locale in the environment (this sounds like the "correct" fix to me and we might implement it later), but this application shares a WebLogic server with many other applications so we would have to do a huge amount of testing to make sure that the locale change wouldn't break the other apps. In the end I worked around the problem by making the code that generates the filenames in the first place strip out any non-ASCII characters (the names of the files are not critically important).
    Looking forward to JSR-203, in the meantime perhaps a note about this behaviour in the java.io.File javadoc would be useful.

  • How can I get the DC component out of a signal in Labview

    I was trying to get the DC component of a signal using lowpass filters provided by Labview(professional version 8.2). I used the FIR windowed filter but I couldn't get what I expected. The sample rate is 20* the maxium signal frequency. I simulated a function like y= 10(volt)+Sin(2*pi*f*t+phase). If I set the low cutoff to be less than the frequency f, shouldn't I get 10 volt as the outputs?  See the attachment for vi. Thanks!
    Attachments:
    Simulation03062008.vi ‏53 KB

    Hi,
    You can use the filters located in Signal Processing -> Filters, then create a constant from the "filter type" input and select "Lowpass". There is also an AC & DC estimator vi, located in: Signal Processing -> Measurement.
    You may also use something like "running mean" filter. To do it you need to calculate the mean value in some range around every point. It will decrease the value of the noise and will give you the dc value (or slow changing part) of your signal. Finally you can use median filter.
    Benjamin R.
    R&D Software Development Manager
    http://www.fluigent.com/
    Attachments:
    meanrun.vi ‏21 KB

Maybe you are looking for