Javamail API doesn't support special characters in attachment file name

Hi,
We are using Java Mail API to retrieve the attachment's file name, but it sometimes returns the file name as junk character (if the attachment contains special characters) and it is not able to return original file name for some attachments:
Our code sample :
void getFileName(Part part) {
String fname=null;
fname = part.getFileName();                          
Actually the problem is with the attachment file name which contains special character. For example below is the attachment file name (please find the sample attached file which is causing this issue):
Sample – 1234abc.doc
From above you could see the file name contains a special character (Sample – 1234abc.doc), i.e. The character ‘–’ is not a regular hyphen character, it’s a special character. Hence the Java mail API returns the name as below:
Sample ? 1234abc.doc
So the special character is being replaced with ‘?’ symbol. But if I store this file in local folder and try reading the file name using Java IO packages, it returns the file name without adding ‘?’ symbol.
Is there any way to handle such kind of special characters in Mail API?
Regards,
Vinodh

We dealt with this issue in a private email conversation.
JavaMail is returning the correct data for the filename.  The problem is in the way the filename is being displayed.

Similar Messages

  • Firefox doesn't reconvert special characters in the file names when download a file with any special characters in the file name

    <blockquote>Locking duplicate thread.<br>
    Please continue here: [/questions/815207]</blockquote><br>
    if i try to download a file with any special characters in file name (e.g. File_Name.pdf), it doesn't reconvert them from the "sanitize url" process and download the file an incorrect name (e.g. File%5FName.pdf).
    This is really annoying.
    Thank you for your patient

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    * Don't make any changes on the Safe mode start window.
    * https://support.mozilla.com/kb/Safe+Mode
    * [[Troubleshooting extensions and themes]]

  • Special Characters in the file name in Data Driven Subscription via File Share

    Hi,
    I am trying to create a Data Driven Subscription with option to delivery as  windows file share in SQL server 2005. I need to save the report as a pdf with the following file name  '[City] City_Name', but it errors out and it is because of the
    Square Brackets. Is there any way i can save the file using the Square brackets as i mentioned above.
    I am using a query to get the filename and filepath. It works fine as long as i do not have [], but i need to save the file as i mentioned along with the Square Brackets.
    Please help.

    Hello,
    I can reproduce the issue on my test environment: When I create a Data Driven Subscription and specify the report name by get from a subscription delivery table, and the value of the "report name" column contains square brackets. The subscription failed
    with following error in the error log:
    ERROR: Error occurred processing subscription ab9523a6-0256-4607-b818-a7666204d018:
    The file name is not valid. Avoid using special characters such as /\?*:<>|+,[]"& in the file name.
    notification!WindowsService_1!1f24!05/30/2014-15:31:02:: i INFO: Notification 0cf5a356-3172-4108-9d8c-58ea81a0b80a completed.  Success: False, Status: The file name is not valid. Avoid using special characters such as /\?*:<>|+,[]"& in the
    file name., DeliveryExtension: Report Server FileShare, Report: Report6, Attempt 0
    It seems that the behavior is by design. please avoid using square brackets as file name. Maybe you can try to use parentheses () instead.
    Regards,
    Fanny Liu
    Fanny Liu
    TechNet Community Support

  • How do I remove spaces and special characters from the file name during rendering?

    I understand that I can set LR_renamingTokensOn to true, but I would like to replace all spaces in the file name with an underscore and remove characters not in the range A-Z and 0-9. What's the easiest way to achieve this?

    local photo = catalog:getTargetPhoto()
    local sesn = LrExportSession {
        photosToExport = { photo },
        exportSettings = {
            -- ... (determine from export preset) - whatev you want, just be sure you set export directory: LR_export_destinationPathPrefix
            LR_tokens = "{{custom_token}}",
            LR_tokenCustomString = LrPathUtils.removeExtension( photo:getFormattedMetadata( 'fileName' ) ):gsub( "[ %c]", "" ) -- remove spaces and control characters
    sesn:doExportOnNewTask()

  • Special characters in the employee names is adding ASCII  to the file

    Hi Team,
    Iam working on a outbound interface which has a length of 3000. For the last name it is having some special charecters Vázquez . When downloading into application server, the special characters in the employee names is adding ASCII characters to the file Vázquez . This is increasing the record length to 3001.
    Please let me know how to remove this ASCII charecters. It is happening only for application server.
    Rgds
    Kishor

    Hi
    Please refer below link.
    [Re: Translation of special charachter like 'u00E3au00EA']
    ~~~Ganesh Kumar K.

  • Restricted Special characters in KM Resource name

    Hi,
    While creating resources in KM, it is not allowing some special characters (ex: '?' , ':') in name.
    How do we know what are all the restricted special characters in KM?
    Please let me know.
    Thanks

    I think the file name restrictions which apply to naming of files on the PC apply to KM Resources as well since the file will have to be created on some file system itself.
    Do refer to [this|http://kb.wisc.edu/page.php?id=2533] link to peek at the list of restricted characters.
    Thanks,
    GLM

  • Special Characters usage in member names

    All,
    As we are aware, essbase member names cannot contain special characters. But as per our business requirement we are in need to use special characters in some member names. Can anyone advise me if there are any work-around available to achieve this. Thanks in advance.
    Regards,
    Ramesh

    866969 wrote:
    Thanks a lot for your response Vasavya. Let me describe my problem clearly. We are having planning application and we use ODI to refresh Master data/Meta data in planning application. One attribute dimension member contains special character and its getting rejected everytime since planning will not accept special characters in member names/Alias names. Is anything that we can do from planning side to avoid the rejection?. Thanks in advance.Is the application been created in unicode mode? Are you able to enter characters directly into planning? have you read the restrictions sections - http://docs.oracle.com/cd/E17236_01/epm.1112/hp_admin/frameset.htm?apb.html
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • Firefox 11 doesn't send letters with big attached files

    Firefox 11 doesn't send letters with big attached files.
    The following letter comes:
    This message was created automatically by mail delivery software.
    A message that you sent could not be delivered to one or more of its
    recipients. This is a permanent error. The following address(es) failed:
    [email protected]
    SMTP error from remote mail server after end of data:
    host ASPMX.L.GOOGLE.COM [173.194.70.27]: 552-5.7.0 Our system detected an
    illegal attachment on your message. Please
    552-5.7.0 visit http://support.google.com/mail/bin/answer.py?answer=6590 to
    552 5.7.0 review our attachment guidelines. u38si3660156weq.136
    ------ This is a copy of the message, including all the headers. ------
    ------ The body of the message is 7642345 characters long; only the first
    ------ 106496 or so are included here.
    Return-path: <[email protected]>
    Received: from localhost ([127.0.0.1] helo=mail.grania.neolocation.net)
    by grania.neolocation.net with esmtp (Exim 4.69)
    (envelope-from <[email protected]>)
    id 1SKxeX-0000OF-UH
    for [email protected]; Thu, 19 Apr 2012 23:08:31 +0300
    Received: from 46.53.195.43
    (SquirrelMail authenticated user [email protected])
    by mail.grania.neolocation.net with HTTP;
    Thu, 19 Apr 2012 23:08:29 +0300 (FET)
    Message-ID: <[email protected]t>
    Date: Thu, 19 Apr 2012 23:08:29 +0300 (FET)
    Subject:
    =?utf-8?B?W0Z3ZDog0JzQsNGC0LXRgNC40LDQu9GLIDE5INCw0L/RgNC10LvRj10=?=
    From: [email protected]
    To: [email protected]
    User-Agent: SquirrelMail/1.4.19
    MIME-Version: 1.0
    Content-Type: multipart/mixed;boundary="----=_20120419230829_38092"
    X-Priority: 3 (Normal)
    Importance: Normal
    Received-SPF: pass (grania.neolocation.net: localhost is always allowed.)
    client-ip=127.0.0.1; envelope-from=[email protected];
    helo=mail.grania.neolocation.net;
    DomainKey-Status: no signature

    This doesn't look like a problem with Firefox, but with the attachment that you are putting on the email is blocked. You can read the link the error message gave you, which basically says that :
    "ade", "adp", "bat", "chm", "cmd", "com", "cpl", "exe",
    "hta", "ins", "isp", "jse", "lib", "mde", "msc", "msp",
    "mst", "pif", "scr", "sct", "shb", "sys", "vb", "vbe",
    "vbs", "vxd", "wsc", "wsf", "wsh"
    Gmail won't accept these types of files even if they are sent in a zipped (.zip, .tar, .tgz, .taz, .z, .gz, .rar) format. If this type of message is sent to your Gmail address, it is bounced back to the sender automatically.

  • [svn:fx-trunk] 10389: Added support for octothorpe in embed file names.

    Revision: 10389
    Author:   [email protected]
    Date:     2009-09-18 07:19:26 -0700 (Fri, 18 Sep 2009)
    Log Message:
    Added support for octothorpe in embed file names.  And here I thought I'd never use the term octothorpe in a sentence.
    QE notes: None
    Doc notes: None
    Bugs: SDK-23033
    Reviewer: Paul
    Tests run: Checkin
    Is noteworthy for integration: No
    Ticket Links:
        http://bugs.adobe.com/jira/browse/SDK-23033
    Modified Paths:
        flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/as3/EmbedEvaluator.java

  • Destination file characters too long (File names) , while copying from one external to another

    I have a external my book fat32 formated and a new mybook ntfs formated external as well.  Now when I copy my files from the fat32 to the ntfs external all files copy fine but some give that destination location file characters are too long, meaning that the file names are too long.  Now I could change the file names but that would conflict with programs that need that file name.  I am using vista ultimate and would like to copy all the files over from the fat32 to ntfs so I can reformat the fat32 to ntfs.  The files got on the ntfs from a simple drag and drop from my IDE NTFS internal hard drive.
    I hope you guys to tell me what to do.
    Thank you :)

    Here's the fix....for error message "your file name is too long to be copied, deleted, renamed, moved" :
    1.   problem is this: the "file name" has a limit on number of characters.....the sum of characters really includes the entire path name; you gotta shorten it first (i.e, if the total number of characters in the file name + Path name are over the
    limit, the error appears).  The deeper your file folder sub levels are, the more this problem will come up, especially when you copy to a subfolder of a subfolder/subfolder of another path ...adds to character limit)
    2.  How do you know which combined file names + path names are too long if  you are in the  middle of a copy operation and this error pops up?  Some files copied but the "long files error message" says "skip" or "cancel" ... but not which
    files are the "too long" ones.  If you hit "skip" or "cancel" the "too long" files are left behind...but are mixed in with non-offender "good" "short name" files.   Sorting thru 1000s of "good" files to find a few "bad" ones manually is impractical.
    3.   Here's how you sort out the "bad" from the "good":
    4.    Let's say you want to copy a folder ..."Football" ...that has five layers of subfolders; each subfolder contains numerous files:
      C:/1 Football / 2 teams/ 3 players/ 4 stats/ 5 injuriessidelineplayerstoolong 
           There are five levels root "1 football" with subfolders  2, 3, 4 and lastly "5 injuries"
    5.    Use "cut" and "paste"  (for example to backup all five levels to a new backup folder):
           select "1 football" ....cut....select target folder....paste 
           ("cut" command means as the files are copied to the target destination, the file is deleted from the source location)
          Hint: avoid "cut" and "paste" to a target folder that is itself a sub/sub/sub folder ...that compounds the "characters over the limit" problem ...because the characters in the sub/sub/sub folder are included in the "file name
    character limit"...instead "paste" to a C:/ root directory.
           Suppose in the middle of this operation...error pops up: "5 files have file names that are too long"  Skip or cancel?
           select "skip"  ...and let operation finish
    6.    Now go back and look at the source location: since the software allows only the "good" "short name" files to be copied (and because you "skipped" the "bad" "Long name" files so they are not copied or deleted) ...all that remains
    in the source location are the "bad" "long name files" (because "good" ones were deleted from the source location after the "cut" operation...the bad ones stick out like a sore thumb.
    7.   You will find ....all that remains in source folders are: the "bad" "too long" files; in this example the "bad" file is in level 5:
          C:/ 1 football / 2 teams /3 players /4 stats /5 injuriessidelineplayerstoolong
    8.   select folder 5 injuriessidelineplayerstoolong (that's right...select folder, not file) gotta rename the folder first.
    9.  hit F2 rename folder..folder name highlighted...delete some of the letters in the folder name:
           like this:   5 injuriessidelineplayers  ....you should delete 'toolong'....from the folder name
    10.  then go into folder 5....and do the same operation ...with the too long file name:
            hit F2 rename file....file name hightlighted...delete some of the letters
               like this:  injuriessidelineplayers.....you should delete 'toolong' from the file name
    11.  Now..."cut and paste"  the renamed file to the target backup folder.  
    The Error message will pop up again if you missed any "bad" files....for example, it will indicate "5 files too long" ....then repeat process 5 times until you fix all of them
    12.     Finally, copy the target destination files back to the source location (when you are certain all source location file folder locations are empty) 

  • Re number of characters in a file name with leopard.. 10.5.3

    re number of characters in a file name with leopard.. 10.5.3
    Is there a limit? in a file or directory name?

    hfs+ == hfs extended, the default filesystem on a current mac...
    http://en.wikipedia.org/wiki/HFS_Plus

  • Blob service doesn't accept special characters

    Hi there,
    We are usign Blob REST API in our product to upload files.
    The doc states about blob names:
     - A blob name can contain any combination of characters, but reserved URL characters must be properly escaped.
    We have problems with uploading files which names contain some special characters, even though they are escaped correctly. We get the following response:
    HTTP/1.1 400 Bad Request
    Content-Type: text/html; charset=us-ascii
    Server: Microsoft-HTTPAPI/2.0
    Date: Wed, 08 Feb 2012 17:11:22 GMT
    Connection: close
    Content-Length: 324
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
    <HTML><HEAD><TITLE>Bad Request</TITLE>
    <META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
    <BODY><h2>Bad Request - Invalid URL</h2>
    <hr><p>HTTP Error 400. The request URL is invalid.</p>
    </BODY></HTML>
    Here's a list of ones we figured out that cause problems:
    0x0081 - (encoded to UTF8 %C2%81 )
    0x007F - (encoded to UTF8 %7F )
    0xE000 - (encoded to UTF8  %EE%80%80 ) - with this one situation is strange. When it's alone we can upload such flie, but if it's followed bya  chinese character, it depends:
    PUT /sync/%EE%80%80.txt HTTP/1.1 <--- success
    PUT /sync/%EE%80%80%E4%A1%90.txt HTTP/1.1 < --- fails (the filename: 䡐.txt)
    PUT /sync/%EE%80%80%E7%BF%BD.txt HTTP/1.1 <--- success (the filename: 翽.txt)
    I don't know how such filenames appeared on the client's system, but they a valid unicode filenames and Windows Explorer, Notepad, etc. handle them well.
    Is this a bug, or documented somewhere? Why there's inconsietency when working with 0xE000 character?
    Thanks,
    IP

    Hi Arwind,
    Thanks for your answer, but the unsupported character in the blob name in your code is missed (myabe due to browser copy).
    Here's the snippet for you to try:
                CloudBlob blob1 = container.GetBlobReference("\uE000\u7FFD");   // <-- Success
                CloudBlob blob2 = container.GetBlobReference("\uE000\u4850");   // <-- causes Bad Request on upload
                CloudBlob blob3 = container.GetBlobReference("\u007F");         // <-- causes Bad Request on upload
                CloudBlob blob4 = container.GetBlobReference("\u0081");         // <-- causes Bad Request on upload
                blob1.UploadFile(@"D:\temp\xxxx.txt"); // <-- Success
                blob2.UploadFile(@"D:\temp\xxxx.txt"); // <-- Fail
                blob3.UploadFile(@"D:\temp\xxxx.txt"); // <-- Fail
                blob4.UploadFile(@"D:\temp\xxxx.txt"); // <-- Fail
    (\u4850 - 䡐 ,  and \u7FFD - 翽)
    Note that these all are valid characters in Windows file system and exist in filenames on our client's computer.
    We are uploading to the cloud, not to the dev storage (though I dont' see any dev storage blob names limitations)
    Sincerely,
    IP

  • [Solved] TTY doesn't display special characters correctly

    Hello everyone.
    I want to set my system language to german. I followed this tutorial: https://wiki.archlinux.de/title/Arch_Li … .BCber_HAL
    Everything works good except that my TTY can't display special characters. Example:
    http://i.imgur.com/ZW6kbOS.png
    The is " not showing correctly at the bottom. However, the german umlaut ä works (as you can see).
    I have already searched the arch forum. The only thing i have found is setting DAEMON_LOCALE="yes" in rc.conf. However, these post are already quite old and don't solve the my problem (as öäü are working). Additionally, Arch has stopped using rc.conf.
    So, what causes this problem and how can i solve it?
    Here are my configs:
    /etc/locale.conf
    LANG=de_DE.UTF-8
    LC=
    locale -a
    C
    de_DE.utf8
    en_US.utf8
    POSIC
    locale
    LANG=de_DE.UTF-8
    LC_CTYPE="de_DE.UTF-8"
    LC_NUMERIC="de_DE.UTF-8"
    LC_TIME="de_DE.UTF-8"
    LC_COLLATE="de_DE.UTF-8"
    LC_MONETARY="de_DE.UTF-8"
    LC_MESSAGES="de_DE.UTF-8"
    LC_PAPER="de_DE.UTF-8"
    LC_NAME="de_DE.UTF-8"
    LC_ADDRESS="de_DE.UTF-8"
    LC_TELEPHONE="de_DE.UTF-8"
    LC_MEASUREMENT="de_DE.UTF-8"
    LC_IDENTIFICATION="de_DE.UTF-8"
    LC_ALL=
    /etc/vconsole.conf
    KEYMAP=de-latin1-nodeadkeys
    Note that i am running Arch as guest in a VirtualBox.
    -- mod edit: read the Forum Etiquette and only post thumbnails http://wiki.archlinux.org/index.php/For … s_and_Code [jwr] --
    Last edited by Oznerol256 (2013-11-01 09:49:08)

    I'm pretty sure you have to specify font and font map in vconsole.conf
    like so:
    FONT=Lat2-Terminus16
    FONT_MAP=8859-2
    If that doesn't help it could be this.
    If so try to load settings manually, I can't test German setup, but for Polish I could do this to get national characters:
    loadkeys pl
    setfont Lat2-Terminus16 -m 8859-2
    that requires to be root/sudo
    note that -m 8859-2 part is quite important
    edit:
    actually got all German symbols to be displayed correctly, though I do not know if they are assigned for right keys for obvious reasons
    loadkeys de-latin1-nodeadkeys
    setfont Lat2-Terminus16 -m 8859-2
    read read topic in then link to hopefuly fix why settings are not loaded on boot
    Last edited by nutsh (2013-10-31 02:47:48)

  • US7ASCII Characterset - Need to support Special Characters & Symbols

    Dear All,
    My database characterset is 'US7ASCII'
    Some of Special Characters / Symbols are not supported by 'US7ASCII'. But those symbols need to be supported by 'US7ASCII'.
    Do we have any option to make 'US7ASCII' Characterset to support such Symbols.
    Details given below.
    Database - Oracle 10g
    NLS_CHARACTERSET - US7ASCII
    Column - Description Varchar2(50)
    Symbols - ↓ β α ↑ З Њ Є € £ ± ¥ © ® ∞ etc......( Greek and Captic, European etc......Symbols stored as ������ )
    My requirement is the above symbols need to be properly stored in the database as it is.
    Kindly help / Guide me on this.

    Hi,
    Database - Oracle 10g
    NLS_CHARACTERSET - US7ASCII
    Column - Description Varchar2(50)
    Symbols - ↓ β α ↑ З Њ Є € £ ± ¥ © ® ∞ etc......( Greek and Captic, European etc......Symbols stored as ������ ) " Euro symbol is neither in US7ASCII nor WE8ISO8859P1 character set.
    You have to use WE8ISO8859P15, WE8MSWIN1252, UTF8..."
    Read Tom [Differrent Character set and NLS|http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1224836384599]
    Twinkle

  • SQL Loader doesn't handle special characters

    Hi All:
    My DB characterset and NLS characterset is UTF8.
    When i tried to insert records with SQL *Loader having special characters, it doesn't get stored correctly, so when i try to get it out thru' SQLPlus Worksheet, it displays garbage characters.
    Do we have to set something in the control file?
    Pls. help.

    You need to create the data file in UTF8 format. For eg. On Win2K, "Save As" in Notepad as UTF8. Or use the uniconv utility to convert the data file to utf8.
    Here is an example of a control file
    'sqlldr32.cnt'
    load data
    infile 'sqlldr32.dat'
    APPEND into table nls_demo
    fields terminated by ',' optionally enclosed by '"'
    (myno char(10),
    myname char(40),
    mydesc char(1000))
    null

Maybe you are looking for