Cfmail/cfmailparam attachment encoding

When a text file is attached to an email, cfmail attempts to determin the mime type of the file and encodes it. This alters the content of the file somewhat. As best I can tell it is at least inserting line breaks. 
Is there a way to attach files that are not encoded or altered in any way?
Thanks for any help. 

This will happen at the recipient's end depending on the mail
server/client they use ... you could send a pdf from your desktop
to the same recipient and it will happen with that too.
It could be a security reflex that it changes the file to a
non-binary format if it is not trusted or seems to be coming from a
questionable source.
A number of the government servers seem to do that - no idea
why, but renaming the file at the recipient's end generally allows
it to open properly.
Nothing you do in your code is going to change that.
*** If you are storing the file on the server, you may want
to include a line in the message that gives them a URL if the
attachment can not be viewed properly.

Similar Messages

  • Cfmail file attachements

    I want to dynamically attach a document and send via cfmail.I
    use various queries to get the recipent names, and unique id info,
    then retrieve the document that corresponds.
    One cfmail documentation says to use cfparam inside cfmail
    and specifiy the full path. Another says to use the mimeattach
    attribute with the full path.
    This is where I am having the problem. My document
    name/variable from my query is #qryName.document#.
    How do I set this up with the path, in either cfparam or
    mimeattach ?

    I understand your code, but I still cannot seem to get the
    correct path.
    I use this query to find th file that I want as an
    attachement to the cfmail :
    <cfquery name="qryName" datasource="dbname">
    select
    uploadFileName
    from tableName
    where docNo = '#form.DocNo#'
    </cfquery>
    So the file that was uploaded with this docNo is stored in a
    variable named uploadFileName in the specifield table.
    What is the full path that I would setup in cfmailparam so
    that this documant is an attachemetn in cfmail ?

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

  • 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

  • CFMAIL w/attachment

    I'm using a simple form to email a text file that I've used
    before with no problems but for some reason it's not going through.
    Either the email goes through without the attachment or doesn't go
    through at all. Should I be be using cfmailparam instead?

    Yes you should use the cfmailparam tag to send the file
    <CFMAILPARAM FILE="#form.file#">
    It looks as though you may need to upload the file first
    before sending.
    <cffile action="upload"
    destination="c:\attachmentsfolder\" nameconflict="MAKEUNIQUE"
    fileField="form.file">
    then you'd use the mailparam like so:
    <CFMAILPARAM
    FILE="c:\attachmentsfolder\#cffile.ServerFileName#.#cffile.ServerFileExt#">
    the cffile. scope will be available after the <cffile
    action="upload" takes place

  • Cfmail with attachment

    I set up a form that emails the form results to an email
    address. It also has an option to attach a file.
    My problem is that when the email is received the attachment
    has been turned into a .tmp file. How can I get it to keep its
    original file extension so that the receiver doesn't have to guess
    the file type in order to open it.
    <cfmail to="[email protected]" from="#FORM.email#"
    subject="Web Site Email" mimeattach="#FORM.uploadfile#">
    </cfmail>
    Any help is greatly appreciated.

    OK if you use a file upload form then the file is uploaded by
    the web server to to a temporary location, this is why the filename
    you have is a .tmp file. If on the action page for the file upload
    you use <cffile action="upload" .../> then you can give the
    file the correct name and extension.
    the next thing you need to understand is that when you send
    an email with cfmail, all you are doing is putting an email in the
    queue for your email server. So when you attach a file to an email
    you must make sure that the file is still there when the mail
    server tries to send the email as that is the point where it
    attaches the file.
    It will stay on your server until you do something about it,
    if this is not the intended functionality then you could use
    cfschedule to remove all files in a folder older than a few hours
    or even a day to be on the safe side.
    In answer to your question about is it accessible to other
    people? Well if it is in your web root and someone can guess the
    URL then yes, but these files do not need to be saved in the
    webroot if they are only to be emailed, so you can protect them by
    saving them elsewhere. Hope that helps!

  • Attachment Encoding in Entourage???

    I am having a problem with attachements using Entourage. I attach JPEG files, they are encoded and sent and everything looks fine. I can go to my sent mail and open them etc. However when they are sent to Windows XP clients they appear as hexadecimal mambo jumbo.
    I have tried the various encoding formats with no luck.
    I have also tested the same files via Mail and they work fine.
    Any suggestions would be much appreciated.
    Cheers
    Daniel

    Using HTML for message composition can sometimes be problematic for image type attachments. This might be caused by the sending and transfer process from and/or between the SMTP server used by the account and the recipient's incoming mail server.
    I know Entourage has a Plain Text option but does it also include a RTF option for message compostion?
    If so, try either one instead of HTML formatting which is tops on my list of the worst things Microsoft wrought upon the internet for email messages.
    If the same occurs using RTF or Plain Text, it is either a problem with Entourage, the SMTP server used by the account or the recipient's incoming mail sever.

  • Email attachment content corrupted, Encoding Issue

    Hi all, I have problem with corrupted email attachments.
    I write JSP codes to send the html file I have created as an ATTACHMENT by using codes:
    messageBodyPart = new MimeBodyPart();
    FileDataSource fds = new FileDataSource(tempAttachment);
    messageBodyPart.setDataHandler(new DataHandler(fds));
    messageBodyPart.setFileName(filename);
    multipart.addBodyPart(messageBodyPart);
    I can successfully send out an email with attachment, however, the attachment when received by Outlook Express, Gmail, Thunderbird are fine without any corruption, but it was corrupted when received with my Outlook 2000. It is totally corrupted and cannot be converted even I change any encodings to view it. Please find below the corrupted text for your reference:
    [email protected]& @{83;g@Z8i 1MGO 6G4B 1MGO@G ?)G` 0hH94c4g@Z0! ?9>`GR 6' A$H.GQ <:8m 9W ?y5eF\=: 9xH#8& >K7AAV=C1b 9Y6x4O4Y.
    I found many resources to help people to do encoding for the mail subject and attachment file name, but coundn't find any for the encoding of the attachment content, many authors even suggest that the email client will do the job for attachment encoding conversion. But, Outlook 2000 sucks, I need to do it explicitly in the coding, would anyone of you help me?
    Thanks a lot for your help and this is urgent, your help is highly appreciated.

    Hey, where are the experts?Maybe the JavaMail experts view the JavaMail forum!
    >
    OMG, people in this forum only know how to get stuff
    from the others and never thinking of sharing your
    knowledge with the others?This is just stupid! If nobody is "sharing your knowledge" then how can others "get stuff"?
    >
    Or there are no experts in this forum???Plenty! Many have written well thought of books on various Java topics.
    I am not an expert in JavaMail but I use JavaMail and have sent JavaMail with attachments to Outlook 2000 but I have never seen your problem. Don't you think it significant that all woks OK except on Outlook 2000! Maybe printing the raw email will help you decide what is wrong.
    P.S. Consider moving the code that sends the email out fo the JSP to a class that can be tested outside the web server. Then if you have a problem you can post more than just a fragment.

  • Attaching generated excel file in cfmail

    Hi,
    I've attached the code in which I've generated an excel file
    from my data, which the user can then open/save on their PC. I now
    want to attach this excel file to an email (using cfmail) and send
    it (the task will then become scheduled).
    How do I save rather than output the excel file?
    Katie

    Hi,
    Have a look at the following tags:
    1)
    <cfsavecontent> to generate a variable from your
    tab-delimited content
    <cffile action = "write"> to generate a temp file with
    your content
    <cfmail> and attach that file to your email
    or
    2)
    <cfsavecontent>
    <cfmail>,<cfmailpart> to attach the variable
    directly to the email without creating a temp file first (have not
    tried that myself)
    cheers,
    fober

  • Cfmail mulitiple attachments?

    This isn't working... please advise. I need to attach
    mulitiple documents.....
    <cfmail to="#t.email#"
    subject="Purchase"
    from="[email protected]"
    password="hdfd"
    username="purchase.request"
    cc=""
    type="html"
    server="mail2.corp.org"
    mimeattach="d:\coldfusion
    applications\pages\onlineforms\purchaserequest\Purchase Order
    Request-#session.purchaserequestid#.pdf"
    > <cfmailparam file =
    "D:\filespload\#session.filename1#" >
    </cfmail>

    You can use multiple cfmailparam tags inside your cfmail to
    attach multiple files. You might try removing the mimeattach
    attribute and use cfmailparam for all your attachments.

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

  • Decode Attachment in OutLook Express .dbx with MimeUtility?

    Hi boys,
    I want to extract an attachment (encoded in base64 format) from outlook express .dbx file.
    I construct 2 classes :
    - the first extract from dbx file the attachment data and write it to disk.
    - the second read from disk and decode with MimeUtility class (JavaMail).
    The result is that the final file decoded is 600 byte less the original.
    sigh!.
    Can Anyone help me?
    Thanks Emanuele
    These are the classes :
    package dbxreader;
    import java.io.*;
    * <p>Title: </p>
    * <p>Description: </p>
    * <p>Copyright: Copyright (c) 2004</p>
    * <p>Company: </p>
    * @author not attributable
    * @version 1.0
    public class Reading // THIS CLASS EXTRACT FROM DBX
    private BufferedReader reader;
    private FileOutputStream output;
    private boolean complete = false;
    public Reading()
    public void parse(String archive,String fileName) throws IOException
    reader= new BufferedReader(new FileReader(archive));
    boolean found=false;
    while(!found)
    String line=reader.readLine();
    if(line!=null)
    int i=line.indexOf("filename=\""+fileName+"\"");
    if(i!=-1)
    found=true;
    extractFile();
    output.close();
    reader.close();
    private void extractFile() throws IOException
    boolean finish=false;
    boolean firstAttempt=true;
    output= new FileOutputStream("solobyte.dat");
    while (!finish)
    char[] buffer=new char[2048];
    byte[] dest;
    int numberfBytes=reader.read(buffer);
    if(firstAttempt)
    dest=new byte[numberfBytes-2];
    byte[] src=new String(buffer).getBytes("iso-8859-1");
    System.arraycopy(src,2,dest,0,dest.length);
    //String stringa=new String(dest);
    firstAttempt=false;
    else
    byte[] src=new String(buffer).getBytes("iso-8859-1");
    dest=new byte[numberfBytes];
    System.arraycopy(src,0,dest,0,dest.length);
    // controllo se il file e finito
    // e scrivo l'array
    String appoggio=new String(dest);
    int index=appoggio.indexOf("------=_NextPart_");
    if(index!=-1)
    byte[] newdest=new byte[index-4];
    System.arraycopy(dest,0,newdest,0,newdest.length);
    System.out.print("Ci sono");
    String prova=new String(dest);
    finish=true;
    String prova2=new String(newdest);
    output.write(newdest);
    output.flush();
    else
    output.write(dest);
    output.flush();
    System.out.print("ciao");
    public static void main(String[] args)
    try
    Reading reading = new Reading();
    reading.parse("Posta in arrivo.dbx", "PathAssolutoW.exe");
    catch (IOException ex)
    ex.printStackTrace();
    THIS CLASS rRECONSTRUCT THE FILE
    package dbxreader;
    import java.io.*;
    import javax.mail.internet.MimeUtility;
    import javax.mail.*;
    * <p>Title: </p>
    * <p>Description: </p>
    * <p>Copyright: Copyright (c) 2004</p>
    * <p>Company: </p>
    * @author not attributable
    * @version 1.0
    public class Decode {
    public Decode() {
    public static void main(String[] args)
    try {
    // FileInputStream file = new FileInputStream(new File("Prova.txt"));
    //FileInputStream file = new FileInputStream(new File("Temp64.txt"));
    FileInputStream file = new FileInputStream(new File("solobyte.dat"));
    InputStream stream = MimeUtility.decode(file, "base64");
    FileOutputStream output =new FileOutputStream("PathAssolutoW.exe");
    //FileOutputStream output =new FileOutputStream("PathAssolutow.exe");
    int iter=0;
    while(stream.available()>0)
    byte[] buffer=new byte[4096];
    int nbytes=stream.read(buffer);
    output.write(buffer,0,nbytes);
    output.flush();
    stream.close();
    output.close();
    // FileOutputStream output =new FileOutputStream("path.exe");
    output.close();
    catch (MessagingException ex)
    ex.printStackTrace();
    catch (FileNotFoundException ex)
    ex.printStackTrace();
    catch(IOException ex)
    ex.printStackTrace();
    }

    The situation is this :
    i have send to myself a mail with an attachment pathassolutow.exe.
    The original file info are(from right click and properties)
    - 85.854 byte dimension
    - 86.016 byte on disk
    When i launch my process (the two classes) the result is:
    - 85.237 byte dimension
    - 86.016 byte on disk
    there is a difference :
    85.854 before
    85.237 after
    If i try to launch the result file i get an error.
    I open the result file(85.237 bytes) with visual studio tool depends.
    I have get an error " NO PE SIGNATURE FOUND.This File is Not a valid win32 module.
    This application write on c a text file.
    Thanks for the reply Emanuele

  • Cfmail attachments not working

    So I have a web page that...
    1 Generates an excel file.
    2 Saves the excel file to my webserver.
    3 Sends an email with the excel file attached.
    If the user opens the email via desktop outlook the attached
    excel file will open and display just fine. If the user opens the
    email via web outlook the attachment won't open. I have no idea if
    this is a coldfusion problem our an outlook problem. Does anyone
    have any idea's what would cause this to happen?
    Thanks

    It opens fine when I double click it on the server. The
    correct tag is
    <cfsavecontent variable="mypage">
    <html xmlns:o="urn:schemas-microsoft-com:office:office"
    xmlns:x="urn:schemas-microsoft-com:office:excel"
    xmlns="
    http://www.w3.org/TR/REC-html40">;
    <head>
    <meta http-equiv=Content-Type
    content="application/vnd.ms-excel; charset=windows-1252">
    <meta name=ProgId content=Excel.Sheet>
    <meta name=Generator content="Microsoft Excel 9">
    <link rel=File-List
    href="./headcountest_files/filelist.xml">
    <link rel=Edit-Time-Data
    href="./headcountest_files/editdata.mso">
    <link rel=OLE-Object-Data
    href="./headcountest_files/oledata.mso">
    Then my table that is getting output
    </cfsavecontent>
    <cfset mypath =
    "C:\mypath\Excel\itinerary_#uname#.xls">
    <cffile action="write" file="#mypath#"
    destination="C:\mypath\Excel" output="#mypage#">
    This creates the excel file and saves it to my webserver.
    I then do my <cfmail> and attach the file that I just
    created. The metatags tell it to create the excel file.

  • Large Mail Attachment Affecting Mail Program

    I have an IMac G5 and use the mail program that came with OS X. The other day I attached a very large movie file to an email I wanted to send to my sister but stupidly, I forgot to compress the movie. I sent the email message but it is now suspended in the "OUT" box and completely slows down my computer and renders the mail program unusable due to its size.
    I've tried deleting the file and email, and even though it says I have, every time I force quit and come back, the file is right back in the "out" box. The little circle keeps spinning indicating that it's working but nothing happens. HOW DO I EXPONGE THIS MISTAKE FROM MY MAIL AND GET MY COMPUTER AND MAIL PROGRAM WORKING REGULARLY AGAIN?
    Please help!
    G5 Imac   Mac OS X (10.4)  

    With the Mail.app quit and using the Finder, go to Home > Library > Mail > Mailboxes > Outbox.mbox.
    Delete the Outbox.mbox folder and empty the Trash.
    Launch Mail and a new Outbox.mbox folder will be created automatically within the Mailboxes folder and this should resolve the problem.
    Depending on the size of the pre-encoded file, the Mail.app uses MIME 1.0 for attachment encoding which is the internet standard. The encoding process increases the size of the pre-encoded file by 50% or so. A 5MB file (pre-encoded) will be roughly 7.5MB after the encoding process.
    Most ISPs and email account providers have limits on the overall size of incoming and sent messages. As an example, a .Mac account has a 10MB overall message size limit for incoming and sent messages and most ISPs and email account providers have similar limits so you need to check on this limit with your ISP or email account provider and the same with the recipient's ISP or email account provider before sending such a large file via email.
    Something else to consider which I'm sure you are aware but just in case, if you can send a 20MB file (encoded size) and the recipient's incoming mail server accepts a message this large for example (which isn't likely) but the recipient has a limited amount of available incoming mail server storage space and the 20MB message exceeds the recipient's server storage space limit, the message will be rejected by the server.

  • Attachment limit

    I was wondering how you increase you attachment limit in Mail. I have a .Mac account and I thought it had something to do with that but now I am confused. I hate having to send more than one e-mail to friends to send them multiple attachments. I guess I could just send a link to my public folder with iDisk. Can anyone access my public folder given the password whether they are on a PC or Mac. Not many of my friends have a Mac.

    This is determined by the email account provider for the account - your ISP if the email account is provided by your ISP or in this case, .Mac.
    A .Mac account has a 10 MB overall message size limit for received and sent messages which is a common limit now but some providers still have a smaller limit.
    If your email account provider has a larger overall message size limit for sending messages but the recipient has a smaller limit, the message will be rejected by the recipient's incoming mail server so you must take the recipient's incoming mail server overall message size limit into consideration.
    Message attachments must be encoded before being sent and decoded when recieved. The Mail.app uses MIME 1.0 for attachment encoding/decoding which is the internet standard. The problem with MIME is it isn't very efficient. The encoding process increases the size of the pre-encoded file by roughly 50% or so. An 8 MB file pre-encoded will be roughly 12 MB in size after the encoding process placing the overall size of the message over the 10 MB limit not taking any message text into account.
    With Hotmail you can just order more space to e-mail files.
    Can you not do this with Mac Mail?
    On a per message basis?
    Not with any email client such as the Mail.app which wouldn't make any difference anyway since the overall message size limit for received and sent messages is determined by the email account provider for the sender and recipient.
    Can anyone access my public folder given the password whether
    they are on a PC or Mac. Not many of my friends have a Mac.
    Yes.
    If you're a .Mac member, you can allow other users to add or remove files from your iDisk Public folder by assigning read-write access to your folder. Assigning read-write access to your Public folder doesn't affect the other folders on your iDisk.
    IMPORTANT: If you assign read-write access to your Public folder, it's a good idea to password-protect it.
    To assign read-write access to your Public folder:
    Open System Preferences and click .Mac.
    Click iDisk, and then click the Read & Write button.
    Your available iDisk storage is affected each time someone adds or removes a file from your Public folder.
    For Mac users:
    You can open another .Mac member's Public folder to see and copy files. If the member has set access privileges to read-write, you can also add and remove files.
    To access another person's Public folder, you need to know their member name and their Public folder password (if they use one to protect the folder).
    To open someone's Public folder:
    Choose Go > iDisk > Other User's Public Folder.
    Type the member name of the person whose Public folder you want to open in the Member Name field.
    Click Connect.
    If a password is required, type it in the Password field and click OK.
    The person's Public folder opens on your desktop.
    For Windows Users:
    If you're using your iDisk to share files with Windows users, they need the following information to see and copy files in your Public folder.
    Windows users can open your iDisk using Microsoft Windows XP, Windows 2000, or Windows 98.
    To access your Public folder, the Windows user needs to know your member name and Public folder password (if your Public folder is password-protected).
    To open someone's Public folder using Windows:
    If you're using Windows XP, use iDisk Utility for Windows to open someone's Public folder. To download iDisk Utility for Windows, go to www.mac.com, and click "iDisk Utility for Windows XP."
    If you're using Windows 2000, open My Computer, choose Map Network Drive from the Tools menu, then click "Web folder or FTP site." Enter the following as the location to add: http://idisk.mac.com/membername-Public? (where "membername" is the other person's .Mac member name).
    If you're using Windows 98, open My Computer, double-click the Web Folders icon, then double-click Add Web Folder. Enter the following as the location to add: http://idisk.mac.com/membername-Public? (where "membername" is the other person's .Mac member name).
    You can also use HomePage to create a file sharing page.

Maybe you are looking for

  • Short Dump Error while executing the DTP

    Hello Experts, I am facing an issue with DTP. Data has been loaded to PSA successfully but while executing the DTP for loading from PSA to DSO (WO) throwing a short dump RAISE_EXCEPTION. Short text     Exception condition "NO_DS_LG_FOUND" raised. "RA

  • Discount pricing is not copied from Qoutation to Sales order.

    Hi All, Issue: Discount pricing is not copied from Qoutation to Sales order. Please suggest the correct copy control/Routine programs which i can check to proceed furthur. Points will be rewarded. Regards, neslin.

  • No rep output caused by incompatible frequency

    Hi All, I wanna to run another rep from a rep using srw.run_report. Here is my code : function BetweenPage return boolean is begin      IF pkg_var.v_loc_from = 'KL' THEN           IF pkg_var.v_loc_to = 'PTI' THEN           srw.run_report('report=tick

  • Downloaded update for Photoshop CS2 but can't access!?

    downloaded update for Photoshop CS2 but can't access to use. What do I do? Virginia

  • Lost IPTC meta data on TIFF import -- old and unsolved problem?

    Hi, this is my first post, after using Aperture on a casual basis for 7 months. Browsing the forum I found the same problem in older threads but the solutions do not help in my case: When I export pictures with IPTC I set in Graphic Converter, metada