File attachment encoding problem

Guys,
I spend to much time trying to get trough this.
I use xsl mapping for preparing to send mail by mail adapter.
File is encoded ANSI (not UTF-8) when i zip it to import it as archive for using this in maaping.
It's realy simple XSL.
It's adding IDOC ORDERS04 as xml attachment.
This is the XSL file:
"<?xml version="1.0" encoding="iso-8859-2"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:rfc="urn:sap-com:document:sap:rfc:functions" version="1.0" exclude-result-prefixes="rfc">
       <xsl:output method="xml" encoding="iso-8859-2" indent="yes"/>
       <xsl:template match="*">
               <ns:Mail xmlns:ns="http://sap.com/xi/XI/Mail/30">
                       <Subject>Order no. <xsl:value-of select="//BELNR" /></Subject>
                       <From>testattest.pl</From>
                       <To>
                       <xsl:value-of select="//RCVLAD" />
                       </To>
                       <Content_Type>multipart/mixed; boundary="--AaZz"</Content_Type>
                       <Content>
AaZz
Content-Type: text/plain; charset=iso-8859-2
Content-Disposition: inline
<xsl:text>Order file.
AaZz
Content-Type: text/xml; name=order.xml
Content-Disposition: attachment; filename=Order no. <xsl:value-of select="//BELNR" />.xml
<xsl:text>
</xsl:text>
      &lt;?xml version=&quot;1.0&quot; encoding=&quot;iso-8859-2&quot; ?&gt;
      &lt;?xml-stylesheet href=&quot;idoc_orders04.xsl&quot; type=&quot;text/xsl&quot;?&gt;
<ORDERS04>
<xsl:text>
</xsl:text>
<IDOC BEGIN='1'>
<xsl:text>
</xsl:text>
<xsl:copy-of select="//EDI_DC40"/>
<xsl:text>
</xsl:text>
<xsl:for-each select="//E1EDK01">
<xsl:copy-of select="."/>
<xsl:text>
</xsl:text>
</xsl:for-each>
<xsl:for-each select="//E1EDK14">
<xsl:copy-of select="."/>
<xsl:text>
</xsl:text>
</xsl:for-each>
<xsl:for-each select="//E1EDK03">
<xsl:copy-of select="."/>
<xsl:text>
</xsl:text>
</xsl:for-each>
<xsl:for-each select="//E1EDK04">
<xsl:copy-of select="."/>
<xsl:text>
</xsl:text>
</xsl:for-each>
<xsl:for-each select="//E1EDK05">
<xsl:copy-of select="."/>
<xsl:text>
</xsl:text>
</xsl:for-each>
<xsl:for-each select="//E1EDKA1">
<xsl:copy-of select="."/>
<xsl:text>
</xsl:text>
</xsl:for-each>
<xsl:for-each select="//E1EDK02">
<xsl:copy-of select="."/>
<xsl:text>
</xsl:text>
</xsl:for-each>
<xsl:for-each select="//E1EDK17">
<xsl:copy-of select="."/>
<xsl:text>
</xsl:text>
</xsl:for-each>
<xsl:for-each select="//E1EDK18">
<xsl:copy-of select="."/>
<xsl:text>
</xsl:text>
</xsl:for-each>
<xsl:for-each select="//E1EDK35">
<xsl:copy-of select="."/>
<xsl:text>
</xsl:text>
</xsl:for-each>
<xsl:for-each select="//E1EDK36">
<xsl:copy-of select="."/>
<xsl:text>
</xsl:text>
</xsl:for-each>
<xsl:for-each select="//E1EDKT1">
<E1EDKT1>
<xsl:copy-of select="TDID"/>
<xsl:copy-of select="TSSPRAS"/>
<xsl:copy-of select="TSSPRAS_ISO"/>
<xsl:copy-of select="TDOBJECT"/>
<xsl:copy-of select="TDOBNAME"/>
<xsl:for-each select="E1EDKT2">
<xsl:copy-of select="."/>
<xsl:text>
</xsl:text>
</xsl:for-each>
</E1EDKT1>
</xsl:for-each>
<xsl:for-each select="//E1EDP01">
<E1EDP01>
<xsl:copy-of select="POSEX"/>
<xsl:copy-of select="ACTION"/>
<xsl:copy-of select="PSTYP"/>
<xsl:copy-of select="KZABS"/>
<xsl:copy-of select="MENGE"/>
<xsl:copy-of select="MENEE"/>
<xsl:copy-of select="BMNG2"/>
<xsl:copy-of select="PMENE"/>
<xsl:copy-of select="ABFTZ"/>
<xsl:copy-of select="VPREI"/>
<xsl:copy-of select="PEINH"/>
<xsl:copy-of select="NETWR"/>
<xsl:copy-of select="ANETW"/>
<xsl:copy-of select="SKFBP"/>
<xsl:copy-of select="NTGEW"/>
<xsl:copy-of select="GEWEI"/>
<xsl:copy-of select="EINKZ"/>
<xsl:copy-of select="CURCY"/>
<xsl:copy-of select="PREIS"/>
<xsl:copy-of select="MATKL"/>
<xsl:copy-of select="UEPOS"/>
<xsl:copy-of select="GRKOR"/>
<xsl:copy-of select="EVERS"/>
<xsl:copy-of select="BPUMN"/>
<xsl:copy-of select="BPUMZ"/>
<xsl:copy-of select="ABGRU"/>
<xsl:copy-of select="ABGRT"/>
<xsl:copy-of select="ANTLF"/>
<xsl:copy-of select="FIXMG"/>
<xsl:copy-of select="KZAZU"/>
<xsl:copy-of select="BRGEW"/>
<xsl:copy-of select="PSTYV"/>
<xsl:copy-of select="EMPST"/>
<xsl:copy-of select="ABTNR"/>
<xsl:copy-of select="ABRVW"/>
<xsl:copy-of select="WERKS"/>
<xsl:copy-of select="LPRIO"/>
<xsl:copy-of select="LPRIO_BEZ"/>
<xsl:copy-of select="ROUTE"/>
<xsl:copy-of select="ROUTE_BEZ"/>
<xsl:copy-of select="LGORT"/>
<xsl:copy-of select="VSTEL"/>
<xsl:copy-of select="DELCO"/>
<xsl:copy-of select="MATNR"/>
<xsl:copy-of select="VALTG"/>
<xsl:copy-of select="HIPOS"/>
<xsl:copy-of select="HIEVW"/>
<xsl:copy-of select="POSGUID"/>
<xsl:text>
</xsl:text>
<xsl:for-each select="E1EDP02">
<xsl:copy-of select="."/>
<xsl:text>
</xsl:text>
</xsl:for-each>
<xsl:for-each select="E1CUREF">
<xsl:copy-of select="."/>
<xsl:text>
</xsl:text>
</xsl:for-each>
<xsl:for-each select="E1ADDI1">
<xsl:copy-of select="."/>
<xsl:text>
</xsl:text>
</xsl:for-each>
<xsl:for-each select="E1EDP03">
<xsl:copy-of select="."/>
<xsl:text>
</xsl:text>
</xsl:for-each>
<xsl:for-each select="E1EDP04">
<xsl:copy-of select="."/>
<xsl:text>
</xsl:text>
</xsl:for-each>
<xsl:for-each select="E1EDP05">
<xsl:copy-of select="."/>
<xsl:text>
</xsl:text>
</xsl:for-each>
<xsl:for-each select="E1EDP20">
<xsl:copy-of select="."/>
<xsl:text>
</xsl:text>
</xsl:for-each>
<xsl:for-each select="E1EDPA1">
<xsl:copy-of select="."/>
<xsl:text>
</xsl:text>
</xsl:for-each>
<xsl:for-each select="E1EDP19">
<xsl:copy-of select="."/>
<xsl:text>
</xsl:text>
</xsl:for-each>
<xsl:for-each select="E1EDP17">
<xsl:copy-of select="."/>
<xsl:text>
</xsl:text>
</xsl:for-each>
<xsl:for-each select="E1EDP18">
<xsl:copy-of select="."/>
<xsl:text>
</xsl:text>
</xsl:for-each>
<xsl:for-each select="E1EDP35">
<xsl:copy-of select="."/>
<xsl:text>
</xsl:text>
</xsl:for-each>
<xsl:for-each select="E1EDPT1">
<E1EDPT1>
<xsl:copy-of select="TDID"/>
<xsl:copy-of select="TSSPRAS"/>
<xsl:copy-of select="TSSPRAS_ISO"/>
<xsl:for-each select="E1EDPT2">
<xsl:copy-of select="."/>
<xsl:text>
</xsl:text>
</xsl:for-each>
</E1EDPT1>
</xsl:for-each>
<xsl:for-each select="E1EDC01">
<xsl:copy-of select="."/>
<xsl:text>
</xsl:text>
</xsl:for-each>
</E1EDP01>
</xsl:for-each>
<xsl:for-each select="//E1CUCFG">
<xsl:copy-of select="."/>
<xsl:text>
</xsl:text>
</xsl:for-each>
<xsl:for-each select="//E1EDL37">
<xsl:copy-of select="."/>
<xsl:text>
</xsl:text>
</xsl:for-each>
<xsl:for-each select="//E1EDS01">
<xsl:copy-of select="."/>
<xsl:text>
</xsl:text>
</xsl:for-each>
</IDOC>
<xsl:text>
</xsl:text>
</ORDERS04>
</Content>
               </ns:Mail>
       </xsl:template>
</xsl:stylesheet>"
When i import it i can view this file when i open imported archive.
There i can see that this is iso-8859-2 encoded file.
When i recive mail and when i save the file it's UTF-8 encoded.
I'm not talking about declaration in XML file etc. There everything is OK.
Just when i open file lets say in Edit++ and check code page for file it's UTF-8.
I need iso-8859-2 code page for the file.
How can i convert it/do this?
I used TextCodepageConversionBean but this is not working for that scenerio.
In file adapter you can choose it.
Thanks for help,
Olek

Are you sure, that your xslt is really used?
In your XSLT I see:
<Content>
----AaZz
Content-Type: text/plain; charset=iso-8859-2
Content-Disposition: inline
The same place in the SXMB_MONI there is:
<Content>
----AaZz
Content-Type: text/plain; charset=UTF-8
Content-Disposition: inline
I assume that you changed the XSLT meanwhile, but the changes are not active.

Similar Messages

  • SharePoint - InfoPath - File Attachment Control Problem

    Hi,
    I have problem with File Attachment Control.
    If I open form via internet browser in dialog mode next I click "Attachment Button", browser automatically open form in new tab without dialog.
    Any ideas?

    Check if below article can help you
    http://www.bizsupportonline.net/blog/2010/04/top-10-questions-infopath-file-attachments/
    http://sharepoint.stackexchange.com/questions/12512/infopath-file-attachment-run-view-instead-of-download

  • File attachment download problem with Chrome

    hi,
    I've been searching for a cure to this problem for days without success. Hopefully someone here will help me fix this annoying problem.
    The problem:
    1. First: When using Chrome (lastest as of today) to open an attachment in emails, Chrome
    always saves the file as download.xyz where xyz is the extension.
    2. Second: Sometimes it saves the file extension correctly, sometimes it just changes to something else like htm, ashx,... where the correct extension should be .doc or .xls.
    I find this only happen with MS Office attachment files. Other browsers like Firefox, IE work just fine.
    What is the problem and possible solution/work around for this?
    We are using MS Exchange 2010 btw.
    Thank you

    Hi Trung,
    Try disabling plug-ins in Chrome and see if it works, if works you can pin-point out the exact plug-in causing the issue.
    Type this in the chrome browser's address bar: 
    about:plugins
    Reference:
    Chrome: Attachments save as attachment.ashx and a number
    Regards,
    Satyajit
    Please “Vote As Helpful”
    if you find my contribution useful or “Mark As Answer” if it does answer your question. That will encourage me - and others - to take time out to help you.

  • Apple mail attachment encoding problem

    I'm having the problem lately that either attachments aren't being decoded properly and the source is displayed in the email or that the entire email is being displayed like this:
    --Apple-Mail-7--951337123
    Content-Transfer-Encoding: quoted-printable
    Content-Type: text/plain;
    charset=ISO-8859-1;
    delsp=yes;
    format=flowed
    FYI
    --Apple-Mail-7--951337123
    Content-Transfer-Encoding: base64
    Content-Type: application/octet-stream;
    x-mac-type=584C5338;
    x-unix-mode=0744;
    x-mac-creator=5843454C;
    name="report.xls"
    Content-Disposition: attachment;
    filename=report.xls
    0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAPgADAP7/CQAGAAAAAAAAAAAAAAABAAAAAQAAAAAAAAAA
    EAAAQAAAAAEAAAD+////AAAAAAAAAAD/////////////////////////////////////////////
    We have the same problems with UTF-8 encoded mails. If I select the Inbox, then select Mailbox -> Rebuild it fixes it, but I need a better solution to fix this. Several others are having the same problem and it seems to be happenning intermittently.
    Anyone have any suggestions?
    macbook pro 1.86Ghz   Mac OS X (10.4.5)  

    duren wrote:
    Some of my clients cannot open these inline images.
    This clients use presumably Outlook 2007. It's not your or Apple Mail's fault, it's a known bug in Outlook 2007 and there is also a Microsoft Help and Support Article from April 2007 about that issue.
    Here -> http://support.microsoft.com/kb/917120
    A workaround is also described there.
    A simple ad hoc solution is to ZIP the pictures before attaching to mail
    Lupunus

  • XPAAJ library export file attachment annotation problem

    Hi,
    I'm using XPAAJ library to export annotations contained in a PDF file to XFDF file. The files which have fileAttachmentAnnotations cannot be exported to XFDF and is giving the exception pasted below. Is there any known issue in XPAAJ library that it doesn't work with FileAttachmentsAnnotations?
    The exception stack trace is given below
    com.adobe.internal.pdf.cos.util.exceptions.PDFCosCastException: expected CosName
    at com.adobe.internal.pdf.cos.CosObject.nameValue(Unknown Source)
    at com.adobe.internal.pdf.cos.CosDictionary.getName(Unknown Source)
    at com.adobe.internal.pdf.PDFEmbeddedFile.getMIMEType(Unknown Source)
    at com.adobe.internal.xfdf.XFDFAnnotationFileAttachment.transformToXFDF(Unknown Source)
    at com.adobe.internal.xfdf.PDF2XFDFAnnotationsReader.outputAnnotations(Unknown Source)
    at com.adobe.internal.xfdf.PDF2XFDFAnnotationsReader.HandleAnnotations(Unknown Source)
    at com.adobe.internal.xfdf.PDF2XFDFAnnotationsReader.parse(Unknown Source)
    at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.ja va:452)
    at com.adobe.internal.pdf.cos.util.Utility.transformToXML(Unknown Source)
    at com.adobe.internal.xfdf.XFDFObject.exportAnnotations(Unknown Source)
    at com.adobe.pdf.impl.PDFDocumentImpl.exportAnnotations(Unknown Source)
    Is there any other product (any adobe or other for that matters) i can use to accomplish the export annotation task. Note that I wouldn't like to use Acrobat SDK or Assembler as they have this ability.
    Any suggestion would help a great deal.
    Thanks
    Ali

    The answer to the first part is that GetIconContents will
    return:
    #type:#linkedIcon
    However, I am pretty sure it is not possible to automatically
    'select'
    the library version in this way.
    Mark
    derekclayton wrote:
    > I have a script that parses through an Authorware (7.02)
    file, gathers
    > information and exports appropriate media. This is done
    on unpackaged files.
    > Everything works great, unless the icon is actually a
    library icon. After
    > selecting the icon...
    >
    > ExportMedia( FileLocation^"_build\\", FALSE, FALSE )
    >
    > If the icon is linked to a library, it results in an
    error dialog indicating
    > that there was no media to export. How do I determine if
    the icon is a linked
    > library icon? And then select the library version? I can
    find no function or
    > variable, no reference within the help, and nothing
    online.
    >
    > What am I missing? Your input will be greatly
    appreciated.
    >
    www.AuthorwareXtras.co.uk
    EuroTAAC eLearning 2007
    www.eurotaac.com
    www.freelists.org/list/flashelearning
    Authorware Media Synchronization Command:
    www.authorwarextras.co.uk --> Commands
    Media Synchronization made easy !

  • Text file attachment in UTF-8 encoding

    Hi
    I have written a program which sends  mails to the users with text file attached. the problem is the text file when you save it to the local desktop ( by clicking on save as ) the encoding is by default ANSI. I want to make the encoding as UTF-8. Is it possible to change this in program?.
    thanks
    sankar

    OPEN DATASET - encoding
    Syntax
    ... ENCODING { DEFAULT
                 | {UTF-8 [SKIPPING|WITH BYTE-ORDER MARK]}
                 | NON-UNICODE } ... .
    Alternatives:
    1. ... DEFAULT
    2. ... UTF-8 [SKIPPING|WITH BYTE-ORDER MARK]
    3. ... NON-UNICODE
    Effect
    : The additions after ENCODING determine the character representation in which the content of the file is handled. The addition ENCODING must be specified in Unicode programs and may only be omitted in non-Unicode programs. If the addition ENCODING is not specified in non-Unicode programs, the addition NON-UNICODE is used implicitly.
    Note
    : It is recommended that files are always written in UTF-8, if all readers can process this format. Otherwise, the code page can depend on the text environment and it is difficult to identify the code page from the file content.
    Alternative 1
    ... DEFAULT
    Effect
    : In a Unicode system, the specification DEFAULT corresponds to UTF-8, and in a non-Unicode system, it corresponds to NON-UNICODE.
    Alternative 2
    ... UTF-8 [SKIPPING|WITH BYTE-ORDER MARK]
    Addition:
    ... SKIPPING|WITH BYTE-ORDER MARK
    Effect
    : The characters in the file are handled according to the Unicode character representation UTF-8.
    Notes
    : The class CL_ABAP_FILE_UTILITIES contains the method CHECK_UTF8 for determining whether a file is a UTF-8 file.
    A UTF-16 file can only be opened as a binary file.
    Addition
    ... SKIPPING|WITH BYTE-ORDER MARK
    Effect
    : This addition defines how the byte order mark (BOM), with which a file encoded in the UTF-8 format can begin, is handled. The BOM is a sequence of 3 bytes that indicates that a file is encoded in UTF-8.
    SKIPPING BYTE-ORDER MARK
    is only permitted if the file is opened for reading or changing using FOR INPUT or FOR UPDATE. If there is a BOM at the start of the file, this is ignored and the file pointer is set after it. Without the addition, the BOM is handled as normal file content.
    WITH BYTE-ORDER MARK
    is only permitted if the file is opened for writing using FOR OUTPUT. When the file is opened, a BOM is inserted at the start of the file. Without the addition, no BOM is inserted.
    The addition BYTE-ORDER MARK cannot be used together with the AT POSITION.
    Notes
    : When opening UTF-8 files for reading, it is recommended to always enter the addition SKIPPING BYTE-ORDER MARK so that a BOM is not handled as file content.
    It is recommended to always open a file for reading as a UTF-8 with the addition WITH BYTE-ORDER MARK, if all readers can process this format.
    Alternative 3
    ... NON-UNICODE
    Effect
    : In a non-Unicode system, the data is read or written without conversion. In a Unicode system, the characters of the file are handled according to the non-Unicode codepage that would be assigned at the time of reading or writing in a non-Unicode system according to the entry in the database table TCP0C of the current text environment.

  • File adapter ISO-8859-1 encoding problems in XI 3.0

    We are using the XI 3.0 file adapter and are experiencing some XML encoding troubles.
    A SAP R/3 system is delivering an IDoc outbound. XI picks up the IDoc and converts it to an external defined .xml file. The .xml file is send to a connected ftp-server. At the remote FTP server the file is generating an error, as it is expected to arrive in ISO-8859-1 encoding. The Transfer Mode is set to Binary, File Type Text, and Encoding ISO-8859-1.
    The .xml file is encoded correctly in ISO-8859-1, but the problem is that the XML encoding declaration has the wrong value 'UTF-8'.
    Does anybody know of a work around, to change the encoding declaration to ‘ISO-8859-1’ in the message mapping program?

    An example of the XSL code might be as follow:
    <?xml version='1.0'?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method='xml' encoding='ISO-8859-1' />
    <xsl:template match="/">
         <xsl:copy-of select="*" />
    </xsl:template>
    </xsl:stylesheet>

  • Problem in file attachment functionality in ERP.

    Problem in file attachment functionality in ERP in Invoice Workbench and PO documents. The error is Page Not Found.
    Regards
    Sridhar

    Please post the details of the application release, database version and OS.
    user11996389 wrote:
    Problem in file attachment functionality in ERP in Invoice Workbench and PO documents. The error is Page Not Found.Please post the steps you follow to reproduce the issue.
    Was this working before? If yes, any changes been done recently?
    Can you find any errors in Apache/Workflow/Database log files?
    Thanks,
    Hussein

  • Problem while sending file attachment

    <strong>Hi,
    I am using java mail api to send mail from a standalone java application. The mail has one html file attachment. I am using the below java program.</strong>
    import java.io.File;
    import java.util.Properties;
    import javax.activation.DataHandler;
    import javax.activation.DataSource;
    import javax.activation.FileDataSource;
    import javax.mail.Authenticator;
    import javax.mail.Message;
    import javax.mail.Multipart;
    import javax.mail.Part;
    import javax.mail.PasswordAuthentication;
    import javax.mail.Session;
    import javax.mail.Transport;
    import javax.mail.internet.InternetAddress;
    import javax.mail.internet.MimeBodyPart;
    import javax.mail.internet.MimeMessage;
    import javax.mail.internet.MimeMultipart;
    public class AttachExample {
    public static void main(String args[]) throws Exception {
    String host = "smtp.gmail.com";
    String from = "[email protected]";
    String to = "[email protected]";
    String fileAttachment = "javamail.html";
    // Get system properties
    Properties props = System.getProperties();
    // Setup mail server
    props.put("mail.transport.protocol", "smtp");
    props.put("mail.smtp.starttls.enable", "true");
    props.put("mail.smtp.host", host);
    props.put("mail.smtp.auth", "true");
    Authenticator authenticator = new Authenticator() {
    public PasswordAuthentication getPasswordAuthentication() {
    String username = "[email protected]";
    String password = "password";
    return new PasswordAuthentication(username, password);
    // Get session
    Session session = Session.getInstance(props, authenticator);
    // Define message
    MimeMessage message = new MimeMessage(session);
    message.setFrom(new InternetAddress(from));
    message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
    message.addRecipient(Message.RecipientType.TO, new InternetAddress(
    "[email protected]"));
    message.addRecipient(Message.RecipientType.TO,
    new InternetAddress(from));
    message.setSubject("Hello JavaMail Attachment");
    // create the mail root multipart
    MimeMultipart mpRoot = new MimeMultipart("mixed");
    // Create a body part to house the multipart/alternative Part
    MimeBodyPart contentPartRoot = new MimeBodyPart();
    // Create the content multipart (for text and HTML)
    MimeMultipart mpContent = new MimeMultipart("alternative");
    // Add text
    MimeBodyPart mbp1 = new MimeBodyPart();
    mbp1.setText("Hello World");
    mpContent.addBodyPart(mbp1);
    // Add html
    MimeBodyPart mbp2 = new MimeBodyPart();
    mbp2.setContent("<P>Hello World</P>", "text/html");
    mpContent.addBodyPart(mbp2);
    contentPartRoot.setContent(mpContent);
    // Add the root body part to the root multipart
    mpRoot.addBodyPart(contentPartRoot);
    // Add an attachment
    MimeBodyPart mbp3 = new MimeBodyPart();
    DataSource source = new FileDataSource("javamail.html");
    mbp3.setDisposition(Part.ATTACHMENT);
    mbp3.setDataHandler(new DataHandler(source));
    mbp3.setFileName("javamail.html");
    mbp3.setHeader("Content-Type", "text/html");
    mpRoot.addBodyPart(mbp3);
    message.setContent(mpRoot);
    message.saveChanges();
    session.setDebug(true);
    // Send the message
    Transport.send(message);
    <strong>
    In my web mail I am not able to find the attachment in inbox/sent item. However I can see the mail is present there.</strong>
    Here is the mail....
    ------=_Part_0_5439109.
    <div class="ii gt">
    1276373943170
    Content-Type: multipart/alternative; boundary="----=_Part_1_14410104.1276373943174"
    ------=_Part_1_14410104.1276373943174
    Content-Type: text/plain; charset=us-ascii
    Content-Transfer-Encoding: 7bit
    Hello World
    ------=_Part_1_14410104.1276373943174
    Content-Type: text/html; charset=us-ascii
    Content-Transfer-Encoding: 7bit
    <P>Hello World</P>
    ------=_Part_1_14410104.1276373943174--
    ------=_Part_0_5439109.1276373943170
    Content-Type: text/html
    Content-Transfer-Encoding: quoted-printable
    Content-Disposition: attachment; filename=javamail.html
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "<a href="http://www.w3/" target="_blank">http://www.w3</a>=<br />
    .org/TR/REC-html40/loose.dtd">
    <html><head>
    <meta http-equiv=3D"content-type" content=3D"text/html;
    charset=3DISO-8859-1=<br />
    <<.....more html code....>><br />
    </div>
    <hr><br />
    =A9 Vipan Singla 2001<br />
    </body></html><br />
    ------=_Part_0_5439109.
    <div class="ii gt">
    1276373943170--<br />
    <br />
    <br />
    <strong>I think I am missing something. Please suggest if you have any idea.<br />
    Thanks In Advance.</strong><br />
    <br />
    <br />
    </div>

    Your posting is full of html markup that this forum doesn't understand, which makes
    it really hard to see what you were trying to say...
    Also, I can't tell whether you're showing us the entire message that was sent,
    or whether you're just showing us part of it. For example, I don't see any From
    or To headers in the message. If they're really missing, something else is wrong.
    If they actually are present in the message, then the rest of what you showed
    looks fine.
    Possibly your web mail isn't able to handle a message that has both a
    multipart/alternative and an attachment? Try a simple plain text message
    with an attachment and see if that works better.

  • Apache-zip.jar name attachment file bad encoding

    I have following code. which create zip archive, but name attachment files bad encoding.
    name attachment files in encoding UTF-8. letters of Russian alphabet -"&#1080;&#1084;&#1103;.txt". get - "¯à¨ï⨥  à鸞.txt" OS - Ubuntu 9.10 64-b
    package action;
    import org.apache.tools.zip.ZipEntry;
    import org.apache.tools.zip.ZipOutputStream;
    import java.io.*;
    import java.util.Arrays;
    import java.util.List;
    public class CreateArchive {
        private byte[] getByteFromFile(String file) throws IOException {
            InputStream is = new FileInputStream(file);
            long length = file.length();
            if (length > Integer.MAX_VALUE) {
                throw new IOException("Size file bad: "+file);
            byte[] bytes = new byte[(int)length];
            int offset = 0;
            int numRead;
            while (offset < bytes.length && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {
                offset += numRead;
            if (offset < bytes.length) {
                throw new IOException("Could not completely read file "+file);
            is.close();
            return bytes;
        public void createZip(OutputStream outputStream, List<String> files) {
            byte[] buf = new byte[1024];
            try {
                ZipOutputStream out = new ZipOutputStream(outputStream);
                out.setEncoding("UTF-8");
                for (String fileName: files) {
                    ByteArrayInputStream sourceStream = new ByteArrayInputStream(getByteFromFile(fileName));
                    out.putNextEntry(new ZipEntry(fileName));
                    int len;
                    while ((len = sourceStream.read(buf)) != -1) {
                        out.write(buf, 0, len);
                    out.closeEntry();
                out.close();
            } catch (IOException e) {
                System.out.print(e);
        public static void main(String[] args) throws IOException {
            CreateArchive files = new CreateArchive();
            OutputStream outputStream = new FileOutputStream("file.zip");
            files.createZip(outputStream, Arrays.asList("&#1080;&#1084;&#1103;.txt"));
            outputStream.close();
    }Sorry for me bad english
    Edited by: P1tBull on Mar 24, 2010 5:35 AM

    Real task was create general archive is selected users files and transmission he in one stream
    package action;
    import org.apache.tools.zip.ZipEntry;
    import javax.servlet.RequestDispatcher;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import java.io.*;
    import java.util.Arrays;
    import java.util.List;
    import java.util.zip.ZipOutputStream;
    public class StreamFiles extends HttpServlet {
        protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            doGet(request, response);
        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            OutputStream out = response.getOutputStream();
            try {
                response.setContentType("'application/zip'; charset='UTF-8'");
                response.setContentType("name=AllFile");
                response.setHeader("Content-disposition", "attachment; filename*=utf-8" + "''" + java.net.URLEncoder.encode("AllFile.zip", "UTF-8") + ";");
                if (request.getHeader("user-agent") != null) {
                    if (request.getHeader("user-agent").indexOf("Safari") != -1) {
                        response.setHeader("Content-Disposition", "attachment");
                        response.setContentType("application/octet-stream");
                    } else if (request.getHeader("user-agent").indexOf("MSIE") != -1 || request.getHeader("user-agent").indexOf("Chrome") != -1) {
                        response.setHeader("Content-disposition", "attachment; filename=" + java.net.URLEncoder.encode("AllFile.zip", "UTF-8"));
                List<String> files = Arrays.asList("catalina.bat", "startup.sh", "version.sh", "tomcat-juli.jar");
                createZip(out, files);
            } catch (Exception ex) {
                request.setAttribute("javax.servlet.jsp.jspException", ex);
                RequestDispatcher requestDispatcher = request.getRequestDispatcher("/error.jsp");
                requestDispatcher.forward(request, response);
            } finally {
                out.flush();
                out.close();
        private byte[] getByteFromFile(String file) throws IOException {
            InputStream is = new FileInputStream(file);
            long length = file.length();
            if (length > Integer.MAX_VALUE) {
            byte[] bytes = new byte[(int)length];
            int offset = 0;
            int numRead;
            while (offset < bytes.length && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {
                offset += numRead;
            if (offset < bytes.length) {
                throw new IOException("Could not completely read file "+file);
            is.close();
            return bytes;
        public void createZip(OutputStream outputStream, List<String> files) {
            byte[] buf = new byte[1024];
            try {
                ZipOutputStream out = new ZipOutputStream(outputStream);
                for (String fileName: files) {
                    ByteArrayInputStream sourceStream = new ByteArrayInputStream(getByteFromFile(fileName));
                    out.putNextEntry(new ZipEntry(fileName));
                    int len;
                    while ((len = sourceStream.read(buf)) != -1) {
                        out.write(buf, 0, len);
                    out.closeEntry();
                out.close();
            } catch (IOException e) {
                System.out.print(e);
    }but mistake on real host don't repeated, so thanks for answer
    Edited by: P1tBull on Mar 24, 2010 8:14 AM

  • Require PDF File attachment in Mail

    Hi Experts,
    I am doing the Proxy-XI-Mail scenario. I am sending the Mail related data like Content, Content_Type from R/3 to XI and configured the Mail receiver adapter.
    R/3 coding:-
    G_ALERT_INPUT-MT_R3REQUEST_MAIL_SEND-MAIL-CONTENT_TYPE = 'application/pdf;name="filename.pdf"'
    G_ALERT_INPUT-MT_R3REQUEST_MAIL_SEND-MAIL-CONTENT = G_CONTENT
    G_ALERT_INPUT-MT_R3REQUEST_MAIL_SEND-MAIL-FROM = From_Mail.
    G_ALERT_INPUT-MT_R3REQUEST_MAIL_SEND-MAIL-TO = To_Mail.
    and then calling the client proxy
    ID Mail Receiver configu:-
      Selected Use Mail Package option
      Content encoding  base64
      Keep attachment option is also selected.
    I am geeting the Filename.pdf in mail as attachment.
    Problem is:- I am not able to open the attached PDF File and error is:- 'Adobe Reader could not open filename,pdf because it is either not a supported file type ot because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded'
    I think some conversions may be required to convert the XML Payload data into PDF file format for the Mail receiver adapter.
    Please suggest
    Thanks & Regards
    Jagesh

    Hi Jagesh,
                 The content  type of the Pdf has to be identified, in order to conver the pdf successfully, You need to perform the conversion usign the PayloadSwapBean the  Module tab. You use this when you want to receive attachment using Mail adapter. You need to configure few steps in Module Configuration
    There you need to mention your MIME header paramenters Content-Type, Content-Description.
    How this can be configured and how process with PayloadSwapBean check the below link
    http://help.sap.com/saphelp_nw04/helpdata/en/2e/bf37423cf7ab04e10000000a1550b0/frameset.htm
    Module Processor
    http://help.sap.com/saphelp_nw70ehp1/helpdata/en/cd/5af7c0c994e24fb0d0088443513de2/content.htm
    Regading  MessageTransformBean, Migrating Dispatcher Classes
    http://help.sap.com/saphelp_nw70ehp1/helpdata/en/57/0b2c4142aef623e10000000a155106/frameset.htm
    Regards,
    Prasanna

  • Http post from an application with file attachment

    Hi ! I didn't know where else to post this message...
    I'm trying to make a HTTP POST from an application and upload a file with it. I have no problems with the posting, just that I haven't got any ideas how to get the file uploaded as well. I've been reading loads of examples regarding the topic, and searching older posts the forum here, without any help.
    Here's the method i'm using:
                   // open connections
                  URL url = new URL ("TheURL");
                   URLConnection urlConn = url.openConnection();
                              // We do input & output, without caching
                   urlConn.setDoInput (true);
                   urlConn.setDoOutput (true);
                   urlConn.setUseCaches (false);
                              // multipart/form-data because we want to upload a file
                     urlConn.setRequestProperty ("Content-Type", "multipart/form-data");
                  // Open output stream
                     DataOutputStream printout = new DataOutputStream (urlConn.getOutputStream ());
                  // Set the actual content
                     String content = "upfile=" + System.getProperty("user.dir") + "\\file.ext&";
                       content += "other_key-value_pairs";
                  // write the data to stream, and flush it.
                     printout.writeBytes (URLEncoder.encode(content));
                   printout.flush ();
                   printout.close ();
                   // Get the response.
                     DataInputStream input = new DataInputStream (urlConn.getInputStream());
                   FileOutputStream fos=new FileOutputStream("postto.txt");
                   String str;
                     BufferedReader bufr = new BufferedReader(new InputStreamReader(input));
                  // Write response to outputfile
                     while (null != ((str = bufr.readLine()))) {
                         if (str.length() >0) {
                         fos.write(str.getBytes());
                         fos.write(new String("\n").getBytes());
                   input.close ();Now, the response here I get from the url i'm posting to is "Failure, no data-file". I've tried many diff methods of writing the file to the stream, but always get the same result.
    I need to file attached like it would be when using a HTML form's <input type="file">.
    Please help ! This is getting really urgent !

    String content = "upfile=" + System.getProperty("user.dir") + "\\file.ext&";
    content += "other_key-value_pairs";
    printout.writeBytes (URLEncoder.encode(content));
    printout.flush ();
    printout.close ();Actually, what this does is create a request like:
    GET /path/to/file/script.language?upfile=/home/user/file.ext&other=params HTTP/1.1
    Content-Type: multipart/form-data
    -- And other HTTP params --
    The file is not actually appended to the request.
    I really don't know how Java handles the file upload, but you could do it by hand, like so:
    public static void doFileUpload(String url, String filename, Hashtable params) throws IOException {
        // Construct the request
        String boundary = "----------------------mUlTiPaRtBoUnDaRy";
        String request_head = "POST " + url + " HTTP/1.0\r\n" +
                                         "Content-type: multipart/form-data; boundary=" + boundary + "\r\n";
        String request_body = boundary + "\r\n\r\nContent-disposition: form-data; name=\"upload\"" +
                                         "\r\n\r\n";
        BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(filename)));
        int b = -1;
        while((b = in.read()) != -1) {
             request_body += (char)b;
        in.close();
        Enumeration keys = params.keys();
        while(keys.hasMoreElements()) {
            String key = keys.nextElement();
            requst_body += "\r\n" + boundary + "\r\n\r\nContent-type: form-data; name=\"key\"\r\n" +
                                    (String)params.get(key);
        request_body += "\r\n" + boundary + "--\r\n";
        int length = request_head.length() + request_body.length() + "Content-length: \r\n";
        String req_length = "Content-length: " + (length + new String("" + length).length()) + "\r\n";
        Socket socket = new Socket(url,80);
        PrintStream stream = socket.getOutputStream();
        stream.print(request_head + req_length + req_body);
        // And now an option to read the response, I will omit that...   
    }Note: I have not tested this code, just wrote it up out of memory. If it does not work, it will propably need some small fixes.
    Tuomas Rinta

  • How to use UTL_SMTP to send email with existing file attachment

    Hello! I am trying to create a pl/sql procedure that lets me send an email and include an existing file to a email address. So far, I found information on how to send a file and create an attachment with information I put in the procedure. This is NOT what I'm trying to do. I'm trying to send an email and include an attachment for a file that already exists. I need the pre-existing file to be sent to the email recipient.
    This is how far I've gotten, but this only allows me to CREATE an attachment with the information I put in it from the procedure. I got it from the following site:
    http://www.orafaq.com/wiki/Send_mail_from_PL/SQL
    DECLARE
       v_From       VARCHAR2(80) := '[email protected]';
       v_Recipient  VARCHAR2(80) := '[email protected]';
       v_Subject    VARCHAR2(80) := 'Weekly Invoice Report';
       v_Mail_Host  VARCHAR2(30) := 'mail.mycompany.com';
       v_Mail_Conn  utl_smtp.Connection;
       crlf         VARCHAR2(2)  := chr(13)||chr(10);
    BEGIN
      v_Mail_Conn := utl_smtp.Open_Connection(v_Mail_Host, 25);
      utl_smtp.Helo(v_Mail_Conn, v_Mail_Host);
      utl_smtp.Mail(v_Mail_Conn, v_From);
      utl_smtp.Rcpt(v_Mail_Conn, v_Recipient);
      utl_smtp.Data(v_Mail_Conn,
        'Date: '   || to_char(sysdate, 'Dy, DD Mon YYYY hh24:mi:ss') || crlf ||
        'From: '   || v_From || crlf ||
        'Subject: '|| v_Subject || crlf ||
        'To: '     || v_Recipient || crlf ||
        'MIME-Version: 1.0'|| crlf ||     -- Use MIME mail standard
        'Content-Type: multipart/mixed;'|| crlf ||
        ' boundary="-----SECBOUND"'|| crlf ||
        crlf ||
        '-------SECBOUND'|| crlf ||
        'Content-Type: text/plain;'|| crlf ||
        'Content-Transfer_Encoding: 7bit'|| crlf ||
        crlf ||
        'This is a test'|| crlf ||     -- Message body
        'of the email attachment'|| crlf ||
        crlf ||
        '-------SECBOUND'|| crlf ||
        'Content-Type: text/plain;'|| crlf ||
        ' name="ap_inv_supplier_cc10.txt"'|| crlf ||
        'Content-Transfer_Encoding: 8bit'|| crlf ||
        'Content-Disposition: attachment;'|| crlf ||
        ' filename="ap_inv_supplier_cc10.txt"'|| crlf ||
        crlf ||
        'TXT,file,attachment'|| crlf ||     -- Content of attachment  (THIS IS MY PROBLEM!  I NEED TO BE ABLE TO ATTACH AN EXISTING FILE, NOT CREATE A NEW ONE)
        crlf ||
        '-------SECBOUND--'               -- End MIME mail
      utl_smtp.Quit(v_mail_conn);
    EXCEPTION
      WHEN utl_smtp.Transient_Error OR utl_smtp.Permanent_Error then
        raise_application_error(-20000, 'Unable to send mail: '||sqlerrm);
    END;
    /

    First, you must create a directory object
    create directory ORALOAD as '/home/ldcgroup/ldccbc/'
    /Study the Prerequisites in the link I posted above, or else you will not be able to read/write files from the above directory object
    "fname" relates to the file name that you read from.
    In the code below, it is also the name of the file that you are attaching.
    Although they can be different!
    l_Output is the contents of the file.
    declare
    vInHandle  utl_file.file_type;
    flen       number;
    bsize      number;
    ex         boolean;
    l_Output   raw(32767);
    fname      varchar2(30) := 'ap_inv_supplier_cc10.txt';
    vSender    varchar2(30) := '[email protected]';
    vRecip     varchar2(30) := '[email protected]';
    vSubj      varchar2(50) := 'Weekly Invoice Report';
    vAttach    varchar2(50) := 'ap_inv_supplier_cc10.txt';
    vMType     varchar2(30) := 'text/plain; charset=us-ascii';
    begin
      utl_file.fgetattr('ORALOAD', fname, ex, flen, bsize);
      vInHandle := utl_file.fopen('ORALOAD', fname, 'R');
      utl_file.get_raw (vInHandle, l_Output);
      utl_file.fclose(vInHandle);
      utl_mail.send_attach_raw(sender       => vSender
                              ,recipients   => vRecip
                              ,subject      => vsubj
                              ,attachment   => l_Output
                              ,att_inline   => false
                              ,att_filename => fname);
    end;
    /

  • I have Windows 7, Microsoft Outlook and PSE 13. I have used the "Share photos as embedded images" feature frequently, but today when I went to use it, it wasn't there, only the option to send email with files attached. How do I get back the ability to sen

    I have Windows 7, Microsoft Outlook and PSE 13. I have used the "Share photos as embedded images" feature frequently, but today when I went to use it, it wasn't there, only the option to send email with files attached. How do I get back the ability to send emails with photos embedded. I like adding the frames and backgrounds and I think it's easier for recipients to look at the photos. Thanks for any suggestions of things to try.
    Gail

    I had a similar problem in that my wife's iphone 5 could not send pics with imessage.  Had to set the settings to default to SMS or whatever.  After laboring many hours on the web I coincidentally was on the phone with the internet people to question my internet speed.  They changed the router channel, which is something that I am capable of doing myself.  After that, the pics go over imessage.  My own Iphone didn't have the problem.  We are both latest IOS 7.0.6.

  • File attachment issue in MimeMessage [Mail API]

    Hi,
    I tried to attach PDF and XML file in MIME Message of MAIL API. I want attach encoded PDF and XML file with gzip format.
    I’m able to attached both the files but its not attached properly and when i tried to retrieved back from MIME Message, I’m getting error.
    Error is
    java.util.zip.ZipException: oversubscribed literal/length tree
         at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:147)
         at java.util.zip.GZIPInputStream.read(GZIPInputStream.java:92)
         at java.io.FilterInputStream.read(FilterInputStream.java:90)
         at com.asite.supernova.test.CreateReadMimeMessage.ReadMail1(CreateReadMimeMessage.java:145)
         at com.asite.supernova.test.CreateReadMimeMessage.main(CreateReadMimeMessage.java:48)
    Here my code
    import java.io.BufferedInputStream;
    import java.io.BufferedOutputStream;
    import java.io.BufferedReader;
    import java.io.BufferedWriter;
    import java.io.ByteArrayOutputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.OutputStream;
    import java.io.Reader;
    import java.io.StringWriter;
    import java.io.Writer;
    import java.util.Date;
    import java.util.Enumeration;
    import java.util.Properties;
    import java.util.zip.CRC32;
    import java.util.zip.Deflater;
    import java.util.zip.GZIPInputStream;
    import java.util.zip.GZIPOutputStream;
    import java.util.zip.ZipEntry;
    import java.util.zip.ZipOutputStream;
    import javax.activation.DataHandler;
    import javax.activation.DataSource;
    import javax.mail.BodyPart;
    import javax.mail.Header;
    import javax.mail.Message;
    import javax.mail.Multipart;
    import javax.mail.Session;
    import javax.mail.internet.MimeBodyPart;
    import javax.mail.internet.MimeMessage;
    import javax.mail.internet.MimeMultipart;
    import org.apache.commons.codec.binary.Base64;
    import com.sun.istack.internal.ByteArrayDataSource;
    public class CreateReadMimeMessage {
         public static void main(String[] args) {
              CreateMail();
              ReadMail1();
         public static void CreateMail(){
              try{
                   Properties properties = System.getProperties();
                 Session session = Session.getDefaultInstance(properties);
                 Message msg = new MimeMessage(session);
                 msg.setSentDate(new Date());            
                 Multipart multipart = new MimeMultipart();
                 BodyPart part1 = new MimeBodyPart();           
                 part1.setFileName("test.pdf");                               
                 part1.setHeader("Content-Type", "application/pdf");
                 part1.setHeader("Content-Encoding", "gzip");
                 part1.setHeader("Content-ID", "PDF");
                 //1
                 compressFile("test.pdf","testpdf.gzip");
                 String encodedData = new String(getBytesFromFile(new File("testpdf.gzip")));
                 //1
                 DataSource ds = new ByteArrayDataSource(encodedData.getBytes(), "application/pdf");            
                 DataHandler dh = new DataHandler(ds);
                 part1.setDataHandler(dh);
                 //part1.setText("This is only text data");
                 BodyPart part2 = new MimeBodyPart();
                 part2.setFileName("test.xml");
                 part2.setHeader("Content-Type", "application/xml;");
                 part2.setHeader("Content-Encoding", "gzip");
                 part2.setHeader("Content-ID", "XML");
                 part2.setHeader("Content-Transfer-Encoding", "base64");
                 //1
                 compressFile("test.xml","textxml.gzip");
                 String dataXML = new String(getBytesFromFile(new File("textxml.gzip")));
                 DataSource ds1 = new ByteArrayDataSource(dataXML.getBytes(), "application/xml");
                 DataHandler dh1 = new DataHandler(ds1);
                 part2.setDataHandler(dh1);            
                 multipart.addBodyPart(part1);
                 multipart.addBodyPart(part2);
                 msg.setContent(multipart);
                 msg.writeTo(new FileOutputStream(new File("MIMEMessage.xml")));
              }catch (Exception e) {
                   // TODO: handle exception
                   e.printStackTrace();
         public static void ReadMail1(){
              try{
                   Properties properties = System.getProperties();
                 Session session = Session.getDefaultInstance(properties);
                 InputStream inFile = new FileInputStream(new File("MIMEMessage.xml"));
                 Message msg = new MimeMessage(session,inFile);     
                Multipart multipart = (Multipart) msg.getContent();
                for (int i = 0; i < multipart.getCount(); i++) {              
                    BodyPart bodyPart = multipart.getBodyPart(i);
                    Enumeration enumHeader = bodyPart.getAllHeaders();
                    String fileExt="";
                    while(enumHeader.hasMoreElements()){
                         Header header = (Header) enumHeader.nextElement();
                         System.out.println(header.getName() + ":" + header.getValue());
                         if(header.getName().equalsIgnoreCase("Content-ID")){
                              if(header.getValue().equalsIgnoreCase("pdf")){
                                   fileExt=".pdf";
                              }else if(header.getValue().equalsIgnoreCase("xml")){
                                   fileExt=".xml";
                    BufferedInputStream inn = new BufferedInputStream(bodyPart.getInputStream());
                    GZIPInputStream gzin = new GZIPInputStream(inn);
                    // Open the output file
                       String target ="File"+i+fileExt;
                       OutputStream outf = new FileOutputStream(target);
                       // Transfer bytes from the compressed file to the output file
                       byte[] buff = new byte[128];
                       int lent;
                       while ((lent = gzin.read(buff)) > 0) {
                            outf.write(buff, 0, lent);
              }catch (Exception e) {
                   // TODO: handle exception
                   e.printStackTrace();
         public static void compressFile(String input,String output) {
              try {
                   // Create the GZIP output stream               
                   OutputStream out = new GZIPOutputStream(new FileOutputStream(output));
                   out =new BufferedOutputStream(out);
                   // Open the input file
                   //FileInputStream in = new FileInputStream(input);
                   InputStream in = new BufferedInputStream(new FileInputStream(input));
                   // Transfer bytes from the input file to the GZIP output stream
                   byte[] buf = new byte[524288];
                   /*int len;
                   while ((len = in.read(buf)) > 0) {
                        out.write(buf, 0, len);
                   int count;
                   while((count = in.read(buf, 0, 524288)) != -1) {
                        System.out.println(new String(buf, 0, count));
                        out.write(buf, 0, count);
                   out.flush();
                   in.close();
                   // Complete the GZIP file
                   //out.finish();
                   out.close();               
              } catch (Exception e) {
                   e.printStackTrace();
         public static byte[] getBytesFromFile(File file) throws IOException {
            InputStream is = new FileInputStream(file);
            // Get the size of the file
            long length = file.length();
            if (length > Integer.MAX_VALUE) {
                // File is too large
            System.out.println("File Len : " + length);
            // Create the byte array to hold the data
            byte[] bytes = new byte[(int)length];
            // Read in the bytes
            int offset = 0;
            int numRead = 0;
            while (offset < bytes.length
                   && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {
                offset += numRead;
            System.out.println("offset : " + offset);
            // Ensure all the bytes have been read in
            if (offset < bytes.length) {
                throw new IOException("Could not completely read file "+file.getName());
            // Close the input stream and return bytes
            is.close();
            return bytes;
    }Please help me asap.
    Edited by: sabre150 on 10-Feb-2011 01:50
    Moderator action : added [ code] tags to make the code readable.

    String is not a suitable container for binary data so unless the two lines
                 compressFile("test.pdf","testpdf.gzip");
                 String encodedData = new String(getBytesFromFile(new File("testpdf.gzip")));actually Base64 encode the file content you are probably corrupting your file.
    I suspect you should be Base64 encoding the compressed file and modifying the mime-type to reflect this.

Maybe you are looking for

  • Email Submit button trying to save

    When I use the email submit button it is trying to save the form instead of attaching it to an email.  Started doing this since changed OS to WIndows 7 from XP

  • DAC, ETL failed due to Post-Etl Script not exist and table not exist.

    When execute the ETL in DAC, it failed when execute the "Change Capture For Siebel OLTP" encounterred the following two type errors. how to fix these errors? The first is the table not exist: ==========================================================

  • User's security level issue

    I have an Administrative and a Limited User accounts on my PC. iTunes works fine under the Administrative account, but in Limited User account I get an error everytime I try to change some kind of configuration option at Preference's window (Edit/Pre

  • Question answered.

    question answered thank you

  • Help, I cannot play songs in itunes since I upgraded to itunes 9

    I updated my itunes two months ago and since then, I have played my songs in itunes. The bar is not moving at all. The videos are playing but without sounds. I tried playing the songs in Windows media player and it does not play either. But the songs