Attachment filename

Hi I'm using JavaMail to send emails (how original...) with attached text files. the problem is that when I attach a file called "c:\mydir\myFile.txt" the user receives an email with an attached file called cmydirmyFile.txt hence knowing the full path to the file on the server ... which is hell of a security hole...
Has anyone got this problem before? how can I solev this?

The following code will help, The dataSourcetakes the actually file (full path), and the line setFileName to set it to any name you'd like you mail recipent to see:
DataSource sourcet = new FileDataSource(fullPathFileName);
bodyPart.setDataHandler(new DataHandler(sourcet));
bodyPart.setFileName("any name you want to set here");
Good luck.

Similar Messages

  • 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.

  • Mail Adapter: original Attachment filename retrieval in Proxy

    Hi,
    I have a Sender Mail Adapter, and the receiver is a proxy, where I need to get the attachment and its details.
    When I execute
    attachment_filename = l_attachment->GET_DOCUMENT_NAME( ).
    it simply returns Attachment-1 etc.
    How do I get the original attachment filename?
    I am on SP16.  
    Regards,
    Puloma.

    HI
    Please refer tihs thread for mail attchments
    Re: Handling attachments of mail
    Scenario to pick the mail with its attachments into XI\Re: Infrastructure required for Mail Adapter

  • Retrieval of attachment filename - receiver mail adapter

    Hi,
    I am using the mail adapter to receive an e-mail into PI. This e-mail has an attached CSV file.
    First, I am using the PayloadSwapBean to swap the application playload to the attachment payload
    Second, I am using the MessageTransformBean to transform the CSV file into an XML document
    These are both working fine and the message is then passing into the relevant message mapping.
    However, I would like to be able to use the attachment filename in the message mapping.
    Can anyone advise how to do this for the mail adapter ?
    I've done it loads of times for the file adapter but never the mail adapter (when using attachments) so I am a bit stumped.
    Any advice greatly received.
    Cheers
    Colin.

    Hi Progirl,
    I want to dynamically set the name of attachment in receiver mail Communication Channel.
    Example: IN__9907211000004_4048454000005_20081211_01000000002643
    The first two numbers 9907211000004 & 4048454000005 I want to read it from the message
    20081211 this is the date and
    And againg this number 01000000002643 is read from message.
    I read from your response. You had created adapter module for the similar purpose. Can you share it. Since I am new to  writing Adapter Module.
    Thank You in Advance.
    Mukhtar

  • ("Content-Disposition", "attachment;filename=x") works in Netscape; not IE.

    I'm sending an ASCII file back to the client using the following method:
    private void sendFile(String fullFilePath, HttpServletResponse res) {
    if(fullFilePath!=null) {
    try {
    res.setContentType("application/text/plain"); //this will be an unknown type
    res.setHeader("Content-Disposition", "attachment;filename=" + fullFilePath);
    FileInputStream fi = new FileInputStream(fullFilePath);
    OutputStream out = res.getOutputStream();
    while(true) {
    int d = fi.read();
    out.write(d);
    if(fi.available()==0)
    break;
    fi.close();
    out.close();
    catch (Exception e) {
    Logger.err.println("Error in TableQueryServlet.sendFile(): " + e,Log.ERROR);
    This works great in Navigator. The filename that it defaults to in the Save file dialog box is the same one I set it to using the fullFilePath string - including the .txt extension. However, in IE it ignores my filename and assigns its own random filename. Any ideas how I can get this to work in IE?

    It's not the greatest, but see the following...
    MS knowledgebase # Q279667

  • Broadcasting Workbook - Change attachment filename

    Software component : BW release 3.5 SP 16
    HI guru,
    we're using Information Broadcasting to distribute precalculated workbooks as attachments (xls-files) to our end users.
    The attachment file in the outsent mail has a generated file name with the following structure :
    workbook_<technical workbook name>.xls
    We have the problem to discern through filename the different workbooks sent with different parameter because the name is always the same.
    So we want to change the generated attachment filename to a more meanful name.
    Does anybody has a way to solve this problem?
    Kind Regards
    Stefano

    Hi,
    the filename is defined in CLASS CL_RSRD_PRODUCER_EXCEL
    on Method PRODUCE
    the code is:
        CONCATENATE 'WORKBOOK_' l_wbid '.' l_creation_type INTO l_sx_document-root-file_name.
    No user exit exist on this part.
    No substitution of variable is possible on that (like rsrd_attr table).
    I'm sorry,
    Regards,
    Sergio

  • Information Broadcaster- change attachment filename

    Hello,
    we're implementing Information Broadcasting to distribute csv-files to our information-consumers.
    Now we have the problem that we want to change the generated attachment filename to a more meanful name.
    Does anybody has a way to solve this problem?
    With kind regards Markus

    HI MArcus,
    Can you please explaint the problem/requirement in detail again?
    Hi Gillan Leo,
    If you don't want to display the footers in the broadcasted email then you  can hide or remove it with settings. Please follow the below path and select for no footer.
    SPRO -> SAP Reference IMG -> SAP Netweaver -> Business Intelligence -> Setting for Reporting and analysis->Settings for Information Broadcasting-> Settings for Distributing E-Mails.
    Please assign points if helpful.
    Thanks,
    Sasi

  • B2B attachment filename having space in UNIX server.

    Hello B2B Gurus,
    I am working on B2B for Rosettanet.
    It also sends the attachment picked from UNIX server along with PIDX format payload.
    If the file name in the UNIX server has a space, Rosettanet along with attachment errors out with
    B2B-51570-
    Machine Info: (hou-ecmsoatst01.swn.com)
    Description: Attachment error
    If the file name does not have any space, the attachment logic works file.
    I used the below link for reference, which was really helpful to attain attachment logic.
    http://anuj-dwivedi.blogspot.com/2011/04/rosettanet-attachment-handling-in.html.
    Can anyone help me to handle filename with space in UNIX server to be sent as attachment.
    Thanks,
    Sunil

    Can you try to escape space with %20 ? For e.g. if file path is file:///b2b file/OrderBill.pdf then provide it as file:///b2b%20file/OrderBill.pdf
    Regards,
    Anuj

  • Reading Attachment FileName in Japanese

    Hai,
    I am Using POP3 for Reading the mail.
    If the mail having attachment , i had get the file name and create the file in the server.
    I have encounter the below problem, when getting the file name in japanese
    if (message.isMimeType("multipart/*"))
    Multipart mp = (Multipart)message[i].getContent();     
         for (int j=0; j<mp.getCount(); j++)
         Part part = mp.getBodyPart(j);
    attachFileName=part.getFileName();
    If the filename is �T���v��.jpg
    I am getting like this iso-2022-jp?B?GyRCJTUlcyVXJWsbKEouanBn?=
    I have tried the below Encoding conversion
    attachFileName= new String(part.getFileName(i).getBytes("8859_1"), "JISAutoDetect");
    attachFileName= new String(part.getFileName(i).getBytes("iso-2022-jp"), "JISAutoDetect");
    still it's not working.
    Expecting Your Feedback.
    Please Help.
    R.vijay.

    attachFileName= new String(part.getFileName(i).getBytes("iso-2022-jp"), "JISAutoDetect");
    try
    attachFileName= new String(part.getFileName(i).getBytes("utf-8"), "JISAutoDetect");
    attachFileName= new String(part.getFileName(i).getBytes("utf-16"), "JISAutoDetect");

  • Rename attachment filename

    Hi,
    I have a watched folder that read a pdf file into document variable in a workflow. In the workflow, the document is copy to an attachment. The problem is that, the filename of the attachment is alway "attach0". How can i change the filename before attach to the workflow?
    I tried setDocAttribute with attribute name "filename", "name", or "file". None of them work.
    Thank you for any help.

    use one of the document object function called setDocumentAttribute. This function takes the document,the attribute to set,attributeProperty
    so to set the filename of the attachment you would use
    setDocumentAttribute(/process_data/documentTochange,"wsfilename","NewName.pdf")
    The document functions can be found in the xpath builder in workbench
    Any further question do let me know
    thanks

  • Possible to show complete attachment filename when printing?

    I know, it's a feature, not a bug.
    Most of the attachments we use in the office have very long filenames (often up to the 31 character limit).
    Mail abbreviates the filename when displaying the attachment icon. That's fine, I can mouse over to see the entire filename.
    But when I print an email, it prints the abbreviation. I'd like to be able to see the entire filename. On emails with multiple attachments, it becomes impossible to distinguish which documents are attached if only the first ten characters are visible.
    Is there a way to adjust settings or run a script so that all attachments can display a full filename?

    it is in fact the same as the bin file for installing
    java, when you extract that you see the license
    agreement and the user has to press enter to go on,
    that's the only input.
    You're right, i should read the out and err, i
    forgot, stupid of meYou have to send enter to the input stream of the process in that case.
    Kaj

  • BExBroadcasting - manipulate pdf mail-attachment filename

    we are broadcasting BW-reports via BExBroadcaster and generated PDFand sending mail-attachements to some BW-users.
    is there any chance to change or manipulate the filename of these generated PDF mail-attachements ?
    e.g.  shorter filename with lower-case Characters (less than 32 char)

    we are broadcasting BW-reports via BExBroadcaster and generated PDFand sending mail-attachements to some BW-users.
    is there any chance to change or manipulate the filename of these generated PDF mail-attachements ?
    e.g.  shorter filename with lower-case Characters (less than 32 char)

  • Mail changes attachment filename

    Mail.app has a bug or disability to properly interpret the filename of received attachments if the filename contains accented characters.
    for example
    the original filename:  xxxxx xxxxxx xxxxáxxxxüxxxxx_xxxxxxxx xxáxáx.pptx
    when received in email: k=5Fxxxxxxxxx_xx=E1z=E1k.pptx?=
    it does not matter what email client is used to send the attachment, it can be any version of Outlook or OS X's Mail, the problem is with Mail.app on recipient side.
    Also it happens to users of 10.6.8 trough to 10.9.1
    What is strange, that this behavior of changing filenames is not consequent:
    in the past before I realized it's a bug, I was usually asking the sender to resend the email as I thought the mail was damaged.
    The sender did nothing else, but resending the email from her/his 'Sent Items' folder, so no change has been made to filename
    or content of the email itself > and strangely the second time the attachment is displayed correctly with proper accented characters,
    no extra letters at the beginning or after the extension.
    I also tried to reproduce this bug, sometimes successfully, but as I wrote this bug is not consistent.
    What worries me that apple knows about this bug for years, but does nothing to fix it - it still exists,
    and non-English users suffer from this.
    https://discussions.apple.com/message/6808962#6808962
    https://discussions.apple.com/thread/1409364?start=60&tstart=0
    https://discussions.apple.com/message/7195409#7195409
    Of course I filled a BUG report, and the purpose of this post is to ask other OS X users to fill a BUG report too and make some pressure
    on apple to fix it for once and for all.
    for non developers a link to bug report: http://www.apple.com/feedback/macosx.html
    for developers:     https://bugreport.apple.com/
    A kindly ask the moderator not to close this Discussion until apple delivers a permanent fix.
    Asking the sender not to use accented characters in filenames is not a solution it's a workaround that nobody will use,
    as it puts everyone in an inconvenient position when exchanging files with clients.
    Thank you.

    Also have this frequently.
    What's more maddening, files within the same message, with the only accented character being the same in each file, and many other files with (different) accented characters, one file gets corrupted, the other one doesn't.
    As in Mail.app:
    The same message appears fine in iOS.

  • ALC-ASM-S00-002 NumberFormatException on attachment filename or source

    DDX:
    <DDX xmlns="http://ns.adobe.com/DDX/1.0/">
      <PDF result="pdfWithAttachments" format="PDF">
       <PDF source="pdfWithoutAttachments"/>
       <FileAttachments source="pic_20140917135051.bmp">
        <File filename="pic_20140917135051.bmp"/>
        <Description>null</Description>
       </FileAttachments>
      </PDF>
    </DDX>
    Error:
    INFO  [com.adobe.livecycle.assembler.AssemblerServiceImpl] ALC-ASM-N00-001: Execute: invoke() begin on thread WorkerThread#1[192.168.126.196:59718] 186
    INFO  [com.adobe.internal.ddxm.Executive] DDXM_N00000: Started processing result named pdfWithAttachments
    ERROR [com.adobe.internal.ddxm.Executive] DDXM_S00001: Failed to assemble result named pdfWithAttachments
    ERROR [com.adobe.livecycle.assembler.AssemblerServiceImpl] ALC-ASM-S00-002: Failed to execute the DDX - error messages provided.
    com.adobe.livecycle.assembler.client.ProcessingException: ALC-ASM-S00-002: Failed to execute the DDX - error messages provided.
    at com.adobe.livecycle.assembler.AssemblerServiceImpl.makeResult(AssemblerServiceImpl.java:906)
    at com.adobe.livecycle.assembler.AssemblerServiceImpl.execute(AssemblerServiceImpl.java:510)
    at com.adobe.livecycle.assembler.AssemblerServiceImpl.invoke(AssemblerServiceImpl.java:454)
    Caused by: java.lang.NumberFormatException: For input string: "20140917135051"
    at java.lang.NumberFormatException.forInputString(Unknown Source)
    at java.lang.Integer.parseInt(Unknown Source)
    at java.lang.Integer.parseInt(Unknown Source)
    at com.adobe.internal.pdfm.embeddedfiles.EmbeddedFilesHandler.updateBaseDocEmbeddedFilenames(EmbeddedFilesHandler.java:947)
    at com.adobe.internal.pdfm.embeddedfiles.EmbeddedFilesHandler.addEmbeddedFile(EmbeddedFilesHandler.java:691)
    at com.adobe.internal.pdfm.embeddedfiles.EmbeddedFilesHandler.importEmbeddedFiles(EmbeddedFilesHandler.java:285)
    at com.adobe.internal.pdfm.attachments.Attachments.importAttachments(Attachments.java:370)
    at com.adobe.internal.ddxm.task.attachments.ImportAttachments.execute(ImportAttachments.java:216)
    at com.adobe.internal.ddxm.ddx.Node.execute(Node.java:353)
    The assembler is parsing the filename or source string (not sure which) and cast the timestamp part to a number ??
    The assembler proces works fine with source and filename "pic_1.bmp"
    Livecycle ES2.0

    UPDATE
    We have installed a new UTF-8 database (Oracle) because the original database was not a unicode database.
    Now the process starts, we no longer get the errors in the server.log
    But now the parameter that contains the mail attachment (pdf) is empty.
    For a normal pdf (no special characters) the parameter is not empty.
    When we change the endpoint by changing the input parameter mapping from *.pdf to * we are able to
    receive the attachment in the input parameter.
    The reason is that the filename (ex. éa.pdf) is being changed to something like "=?ISO-8859-1?Q?=E9a=2Epdf?=".
    Hereby *.pdf does not match and the parameter is empty.
    By changing the endpoint we are now allowing all types of attachments. (ex. xls, doc,..)
    We only want pdf documents.
    In the proces we can get the documentname by using getDocAttribute(/process_data/@inPdfDoc, "wsfilename").
    Since this returns "=?ISO-8859-1?Q?=E9a=2Epdf?=" it's not clear what kind of document this is.
    For é.pdf, "=?iso-8859-1?B?6S5wZGY=?=" is begin returned (not even the letters "pdf").
    Does anyone know a way to solve this?
    Does anyone know a way to get the type of the attachment since the documentname is not a solution...

  • Email attachment filenames appear as "mail attachment".doc or "mail attachment."pdf

    Hi,
    I have Mac OS 10.7.5, I've synchronised my hotmail/outlook address to Mail application.
    I have no issues with sending or receiving emails with attachments.
    The problem I'm having is that the filename of all attachments appear as "mail attachment.doc" for Word files or as "mail.attachment.pdf" for PDF files.
    1)  If I log on to my hotmail account through the browser the attachments appear with the correct file name.
    2) The attachment file names happen to also appear correctly on my iPhone.
    3) I have other mailboxes set up in Mail application and attachment file names appear correct.
    It seems to be an issue with Mail application and the hotmail/outlook account.
    I would appreciate if anyone can give me some feedback on this issue.
    Kind regards,
    Doble Korona

    Peter
    Some things to try - after each step, see if it works...
    Ensure that you have the latest version of the OS and Quicktime and iPhoto.
    1. Repair Permissions using Disk Utility
    2. Delete the com.apple.iPhoto.plist file from the home / library / preferences folder. You'll need to reset your User options afterwards.
    3. Download BatchMod from
    http://macchampion.com/arbysoft/
    And apply it to the iPhoto Library Folder using the settings found here:
    http://homepage.mac.com/toad.hall/.Pictures/Forum/BatChmod.png
    (Credit to Old Toad for this one).
    4. Create a new account (systempreferences -> accounts) and see if the problem is repeated there. If it is, then a re-install of the app might be indicated. If it's not, then it's likely the app is okay and the problem is something in the main account.
    Regards
    TD

  • New email with attachment filename as Mail Subject

    Does anyone know how to make an OSX Service, much like "New Email with Attachment" where the attachment's filename is automatically copied into the subject field of the email?
    Can this be done in Automator, or does a script have to be written from scratch?
    Thanks in advance

    As I said, it is now under Share>Email.
    Also, you can do the same thing just dragging an item to the Mail icon in the dock.

Maybe you are looking for

  • Oracle 8.1.7 on AIX 5.3

    I have existing Oracle Database 8.1.7 running on AIX 5.2. My plan is to install 11g Software as different ORACLE_HOME and upgrade 8.1.7 to 11g Based on 11g documentation looks like it only works with AIX 5.3 . So my question is if we upgrade AIX leve

  • EA1 - consumes a lot of CPU

    New 2.1.0.62 EA1 consumes a lot of CPU on my Macbook with MacOS 10.6.1. After I have opened two database connections (Oracle) everything seems to be fine (CPU usage 2% and below), but after I have executed some sql statements I will never get below 7

  • Query About Cisco WLC 2504 TDLS

    Dear Friends, One of my client want to encrypt data over the wireless. I have cisco WLC 2504 IOS Version 7.2.0.0. Please help me on this. I think by-default data encrypt is enable. If not so how can I enable it. If I enable it is there any impact to

  • I use firefox 16 on windows 7 with Xmarks and now all my bookmarks are gone.

    I recently began using Xmarks with Firefox 16 on a Windows 7 platform. I got some sort of an error message (I think from Xmarks) regarding "Bookmarks". I clicked on the message to fix the problem and zapp all my bookmarks were gone. I found my "bookm

  • Why can't I include a SD card to time Machine backup

    This is a bit of a weird issue. Got a 64GB Micro SDXC card and mini usb adapter to give the 128GB MBA (running 10.7.4) a bit of space as it was running out of space. I formatted the drive to OSX journaled and moved the iPhoto library to it, all good.