Saving attachment problem

Hi, I just wrote a java code for reading mail and store the attachment on a specific folder. It works for 90%, but with some mails the system sees well that it's a multipart/mixed mail, but when I use the getDisposition() it's allways return a NULL value !!!!. I printout the getcontent and getcontenttype ... it shows the same for all mail/attcahment ... So I need help, because I can't see where the problem is. Thanks for prompt answer. here can you fina a part of the code :
for(int i=0;i<msg.length;i++)
          System.out.println("Message is: " + msg.getContentType());
if(msg[i].isMimeType("text/plain"))
System.out.println("Sender: "+msg[i].getFrom()[0]);
System.out.println("Subjet: "+msg[i].getSubject());
System.out.println("Text: "+(String)msg[i].getContent());
          try
          Connection con=null;
          Class.forName("oracle.jdbc.driver.OracleDriver");
          con=DriverManager.getConnection("jdbc:oracle:thin:@xxx","xxx","xxx");
          Statement s=con.createStatement();
          res = s.executeQuery("xxx" );
          Nbr = 0 ;
          while (res.next())
                         Address OriginalSender = msg[i].getFrom()[0];
                         System.out.println("Original Address = " + OriginalSender );
          OriginalSender2 = OriginalSender.toString();
                    } // while
               String str = (String)msg[i].getContent();
               ..... some coding
          s.close();
          con.close();
               catch(Exception e){e.printStackTrace();}
else
               if(msg[i].isMimeType("multipart/*"))
System.out.println("Sender: "+msg[i].getFrom()[0]);
System.out.println("Subjet: "+msg[i].getSubject());
/*Multipart mp = (Multipart)part.getContent();
     level++;
     int count = mp.getCount();
     for (int i = 0; i < count; i++)
//getMessageBody((Part)mp.getBodyPart(i)); //loop back into the same method
level--;*/
Multipart multipart = (Multipart)msg[i].getContent();
               System.out.println("multipart: "+ multipart);
          Part part = multipart.getBodyPart(i);
          MimeBodyPart mbp = (MimeBodyPart)part;
          System.out.println("MimeBodyPart: "+ mbp);
               System.out.println("attachment: "+ part);
               String contentType = part.getContentType();
               System.out.println("Content: "+ contentType);
               InputStream input = part.getInputStream();
               System.out.println("Input: "+ input);
               if(contentType == null)
               System.out.println("Invalid Type");
               else
               String disp = part.getDisposition();
               System.out.println("disp = " + disp);
               if(disp!=null && (disp.equalsIgnoreCase(Part.ATTACHMENT)||disp.equalsIgnoreCase(Part.INLINE)))
                    //if(contentType.startsWith("image/")){
                    String filename = part.getFileName();
                    System.out.println("filename : " + filename);
                    //InputStream input = part.getInputStream();
                    File SaveAttach = new File("C:/"+ filename);
                    FileOutputStream fos=new FileOutputStream(SaveAttach);
                    BufferedOutputStream bos=new BufferedOutputStream(fos);
                    BufferedInputStream bis=new BufferedInputStream(input);
                    int c;
                    while ((c =bis.read()) != -1)
                    bos.write(c);
                    bos.flush();
                    bos.close();
                    bis.close();
Attach = "Attach" ;
               ... coding for reply of this mail
System.out.println("End of messages");

You are right.
If I use input stream from a file I have the same problem:
<%@ page import="java.io.*" %>
<%
try{
     FileInputStream is = new FileInputStream("c:/x.jpg");
     response.setHeader("Content-Disposition", "attachment;filename=\"x.jpg\"");     
     response.setHeader("Cache-Control", "no-cache");
     response.setHeader("Pragma", "no-cache");
     int i;
     while ((i = is.read()) != -1) { out.write(i); }
     out.flush();
     out.close();
     is.close();
catch(Exception e) { }      
%>strange. do I need a special directive ?

Similar Messages

  • Help - PDF Attachment Problem

    Hi,
    Receently, some of our users experienced pdf attachment problem. The user sent a 4mb pdf attachment but after the mail was sent out it only showed 4k in sent item. When the recipient received the e-mail the attachment also showed 4kb and it can't be opend too. These users are using Outlook 2000 and our Exchange server is 2000 Enterprise.
    Thanks for the help,
    JY

    Hi Suresh,
    I just tried this thing in my systtem and it is working... BADI is trigerred everytime there is a change in the PO... even when you release there is a change in the PO so this BADI will be triggerred....
    I suggest you should implement BADI in your dev system and place a break point in the POST method...
    After that create a PO and release it using ME29N... thereafter when you save the PO... this method will trigger and you will have access to PO details...
    PS: Remember this BADI wont work for transaction ME29...
    Regards
    Gautam

  • Pdf attachment problems on osx lion

    Hello
    i was wondering if apple has fixed the pdf attachment problem seen on other iOS' such as 7.1.  I get the same error (blank pdf file, white screen), however, it doesn't happen all the time. 
    any explanations and comments would be greatly appreciated!

    OS 7 or IOS 7?
    If IOS 7, try the iPad community.
    iPad Community

  • New document: How to avoid known PDF email attachment problems

    Have you ever had problems with PDF attachments sent from Adobe Reader for iOS using Share > E-mail Document?
    You may find this document useful to avoid the problems.
    How to avoid known PDF email attachment problems
    Please let us know if you have encountered different types of problems with PDF attachments.  We can look for solutions or workarounds for you.

    Unfortunately, we (Adobe Reader mobile team) do not know if/when Apple will fix the attachment problems (software defects) in Apple Mail.
    In particular, the attachment problem with Microsoft Outlook (See Problem #2 in How to avoid known PDF email attachment problems) appears to be a long-standing defect that has been known for years.  However, Apple has not provided any fix for Apple Mail yet.
    Adobe Reader for iOS merely launches Apple Mail (the default mail app on iOS) to send a PDF document as an attachment.  Adobe Reader has no control over whether or not to embed a preview image of an attachment in the body of an email message, which is known to cause the problem with Microsoft Outlook (on the receiving side).  The same problem happens when you send a single-page PDF document as an attachment along with an email signature from Apple iBooks on iOS.
    For now, all iPad/iPhone users can do is to avoid the problems by using the workarounds that are described in How to avoid known PDF email attachment problems.
    When new and different problems with PDF attachments are reported by Adobe Reader for iOS users, we will update the document above.
    Sorry for the inconvenience.

  • BEx Broadcast email attachment problem with Lotus

    In our BW system, broadcasting with email have attachment problem when we look at SOST we can see email has mhtml attachment and looks fine but end-user does not get the attachment. Email server is Lotus and we think that problem is Lotus configuration related. Anyone having same problem come to a solution, help would be appreciated.
    Thanks in advance

    OK.

  • Mail is not saving attachment and save as is not working

    Suddenly my Mail is not saving attachment and save as is not working. I tried to save an email as I use to do but it is not completing the task. I should I do?
    Thanks for any help,
    Mario Lordeiro

    Mario,
    Was there also NO choice to View As Icon, in the contextual menu? If not, these items/images may be embedded in HTML, rather than true attachments. Other choices for normal attachments would include Open Attachment, Open With, Save to Downloads Folder -- are any of those present in the contextual menu?
    With such a message open, click on View in the menubar, place the cursor on Message in the pull-down menu, and choose Raw Source. Is there any HTML code present? Is there a header immediately before any code representing what you believe is an attached file?
    If need be, I can send you an email message with a known form of attachment.
    Ernie

  • Problem saving attachment via jsp

    Hi,
    I try to save an attachment via jsp, but the attachment has wrong size(2 bytes more). Here is my code:
         Part part = multipart.getBodyPart(partIndex);
        ContentType ct = new ContentType(part.getContentType());
        response.setContentType(ct.getBaseType());     
         response.setHeader("Content-Disposition", "attachment;filename=\""+part.getFileName()+"\"");     
         response.addHeader("Pragma", "public");
         response.addHeader("Cache-Control", "max-age=0");
         InputStream is = part.getInputStream();
         int i;
         while ((i = is.read()) != -1)
           out.write(i);
         out.flush();
         out.close();is it something wrong with the header?
    any idea?
    thx.

    You are right.
    If I use input stream from a file I have the same problem:
    <%@ page import="java.io.*" %>
    <%
    try{
         FileInputStream is = new FileInputStream("c:/x.jpg");
         response.setHeader("Content-Disposition", "attachment;filename=\"x.jpg\"");     
         response.setHeader("Cache-Control", "no-cache");
         response.setHeader("Pragma", "no-cache");
         int i;
         while ((i = is.read()) != -1) { out.write(i); }
         out.flush();
         out.close();
         is.close();
    catch(Exception e) { }      
    %>strange. do I need a special directive ?

  • Character- and attachement problems by E-Mail recipients

    After upgrading to OSX Tiger and using Mail, I am experiencing problems by some of our customers using MS Outlook.The Danish characters ÆØÅ (æøå) are transformed into hieroglyphs, making the message look rather silly, if not unreadable. Also some of them can't locate (JPEG) attachements in the E-mail - they appear as picture in the mail, but can't be saved as files. The problem is only concerning JPEG-files - PDF's and ZIP's work allright. Other MAC- and PC users have none of the problems.
    Any proposals?
    G5 Power Mac   Mac OS X (10.4.4)  

    This is an Outlook problem (especially if other Mac and PC/Windoze users have none of these problems) and I believe it may depend on the Outlook version the recipient is using.
    Sounds like you are using RTF for message composition and if so, try using Plain Text instead.

  • Quik save not saving attachment - Outlook Intergration

    Hi All,
    My client when saves an  e-mail with attachment as an Activity using the Quick Save email option in Outlook It just saves the email as an Activity but no attachment. The email attachment is getting saved only if using the normal Save email as Activity option.
    Has anyone come up with this kind of problem ? Any help is appreciated.
    regards
    Johnson

    Hi Johnson,
    I believe that is due to system issue.  If you choose Quick Save, something may be omitted depending on your setting.  If you need attachment, it is better not select Quick Save.
    Thanks,
    Gordon

  • Cl_gos_manager ,attachment problem

    hi all,
    using cl_gos_manager ,user can attach files and saving it, when execute the program again attachments are not there, what may be the problem.

    Hi kiruthika,
    Please let me know if you get any solution for this: We have a simliar thing in our system: We use the GOS with own business object to store certain PDF documents as attachment. This works fine. User used the built-in functionality of adding own attachments like i.e. mail documents.
    Now a bug was reported that the attachment can be added to the attachment list (visible!) but after leaving transaction it is lost. We found out that, if already an attachments exists, the new attachment does not get lost.
    This looks similar to your case.
    Regards,
    Clemens

  • E61: saving attached files

    Hello,
    I'm regularly stumbling on a recurrent problem with the built-in email application on my E61: when I receive an attached file which is not supported by the phone, I can't save it to the phone's memory or the memory card.
    The only menu I get is "open" (well, in addition to the "send" menu which isn't helping much here) and, of course, since the file isn't recognized by the OS, I only get an error message ("Impossible d'ouvrir. Type d'objet non supporté", i.e. Impossible to open, unsupported object type).
    Is there any workaround for this bug? I mean, the file is just an opera bookmark, basically a html file except that its name ends with .adr instead of .htm, and the only thing I need to reach the data inside this file is simply to save it to the memory, rename it, and open it in the browser...

    kindly can you tell the procedure....there is no Option of saving,there are just four options 'open', 'send','help','exit'
    so how can i save it, as it is attached with some application, but a sw is there to open the attaced file..i want to save it on my phone memory as a file.

  • Thunderbird: Opening an attachment yields a size zero file; saving attachment is okay (MacOSX)

    For quite a while there was no problem, but after one of the updates a couple of months ago, double-clicking or selecting "open" on an attachment yields a size 0 file (with the correct name) in my Downloads directory. Saving the attachment works fine.

    Hi,
    is the next part of the code correct.
    What i mean is packing of the attachment, finding out the size of pdf file and doc type as PDF.
    You can also try below link..
    Link: [http://wiki.sdn.sap.com/wiki/display/Snippets/SENDALVGRIDASPDFATTACHMENTTOSAPINBOXUSINGCLASSES]
    Hope this helps.
    Regards,
    -Sandeep

  • Mime-attachment problems on iOS 6.1.3

    Hello all,
    I have a problem with multiple iPads running iOS 6.1.3. that I can reproduce every time, and would like to verify whether anyone else can confirm that behavior.
    Environment:
    - Apple iPad 4th Generation, Wi-Fi, 32 GB
    - Apple iPad 4th Generation, Wi-Fi + 3G, 64 GB
    - both iPads run iOS 6.1.3
    - open Outlook 2013 on local PC, select any two e-mails and click forward (those two e-mails will be added as attachments to new message ... extension .eml).
    - add another attachment (e.g. pdf file) to that new message and send it to e-mail address of account that you configured in your iPad Mail app.
    - open received e-mail through your iPad Mail app. Click "Download full message". When download completes, open "mime-attachment". Mail app crashes / closes.
    What I've tried:
    - turn on/off iPad (soft/hard (restart))
    - removed e-mail account from iPad and added e-mail account again
    - turned off all running applications, started Mail app ...
    Multiple iPhones running iOS 6.1.3 successfully display "mime-attachment" from e-mails created in described way.
    Thanks, MS

    Additional info:
    I've installed iPhone configuration utility and collected console log of crash ...
    Aug 30 19:00:57 IT1 MobileMail[629] <Warning>: Autoselection cancelled for message 515
    Aug 30 19:00:59 IT1 kernel[0] <Debug>: launchd[651] Builtin profile: syncdefaultsd (sandbox)
    Aug 30 19:01:02 IT1 lockdownd[46] <Notice>: 01584000 _receive_message: walk away - non-SSL 1
    Aug 30 19:01:03 IT1 MobileMail[629] <Error>: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: key cannot be nil'
    *** First throw call stack:
    (0x332183e7 0x3b0a2963 0x3317a5ef 0x162eb1 0x35112087 0x13feed 0x13ff37 0x8873cb3 0x35144c61 0x3510c3a1 0x352f9163 0x35030883 0x3502f2cd 0x3503a1e7 0x35039db3 0x350278e1 0x350271ef 0x36d1b5f7 0x36d1b227 0x331ed3e7 0x331ed38b 0x331ec20f 0x3315f23d 0x3315f0c9 0x36d1a33b 0x3507b2b9 0xfefdf 0x3b4cfb20)
    Aug 30 19:01:04 IT1 ReportCrash[652] <Notice>: Formulating crash report for process MobileMail[629]
    Aug 30 19:01:04 IT1 ReportCrash[652] <Error>: libMobileGestalt copySystemVersionDictionaryValue: Could not lookup ReleaseType from system version dictionary
    Aug 30 19:01:04 IT1 ReportCrash[652] <Notice>: Saved crashreport to /var/mobile/Library/Logs/CrashReporter/MobileMail_2013-08-30-190103_IT1.plist using uid: 0 gid: 0, synthetic_euid: 501 egid: 0
    Thanks, MS

  • Email attachment problems with "excel" files.

    I have just upgraded to the iphone 4 from the 3gs and since doing so any emails I receive with excel files attached will not open the attachment? These files openened with no problem on the same email account on my 3gs.
    Instead when I download the attachment and go to open it I am met with a page displaying....
    "Unable to read document.
    An error occured while reading the document."
    Has anyone else having this problem or even better anyone know what the fix is to get these files showing up?
    Any help would be appreciated,
    Kris

    After much frustration about excel files not opening and repeatedly not getting answers from apple, I think I might have found another way. It seems that the new apple OS does not support older versions of excel. By saving the excel file in question (Save As) to "Microsoft Excel 2007 Workbook" the Workbook opens just fine as an E-mail attachment. If you have macro's you can save as "Microsoft Excel 2007 Workbook (Macro Enabled)" and it works also.
    The Workbook in question as far as I was concerned was created in Microsoft Excel 2003.
    Hope this helps
    Apple needs to get on the ball. This was almost a dealbreaker with me.
    Android is looking better and better every day.

  • How can I search for files in the "Save As" dialogue when saving attachment

    I receive a lot of graphics via email that are updates to existing graphics for a website. When I click on "Save Attachment As..." on the pop-up menu within Mail, a finder-like window appears that has a little search oval on it. I would like to be able to use this to find an existing file on my hard drive that I can select and replace with the file that I'm attempting to save. The only thing that I'm able to bring back is folders. Even when I click on "filename" and use the + sign and change to "name". No files appear in the search. When I get to the folder that I want, I still have to scroll forever to find the file name that I'm looking for. Can anyone tell me what I'm doing wrong or possible offer a better solution to my problem? Thanks in advance for any advice.

    You can enable the Finder to include System files in its search
    In a Finder finder window select Kind then Other… locate System files in the list and click the checkbox.

Maybe you are looking for

  • Warning: xf86-video-nouveau 0.0.15_git20100117-1 may rename outputs

    After this nouveau update, when I next started X, I no longer had two monitors side-by-side, but instead had them in mirrored mode. A little investigation showed that my outputs were renamed: DVI-I-0 -> DVI-I-1 VGA-0 -> VGA-1 This broke my xrandr con

  • Accessing oracle with web dynpro

    Hey people! I want to access a simple sql query on an oracle database and write the output in web dynpro.. Do i have to make an ejb for that? an how do i do that? or is it an easier way?

  • Data migration tools in sap

    hi, i am newbie to s.a.p nd i got ma project related to data migration. we are taking data from legacy system to sap database. we are using a tool called cransoft. what about the future of this tool. how to plan my career in this data migration.need

  • Photoshop: Printing: via Mac from printer on Windows 7

    Hi all, First off - if you know a better place I should be posting this question, please inform. I'm trying to print from Photoshop onto a printer connected via a windows computer. I've tried everything and am nearly at the point of paying somebody 4

  • MacBook Pro 15 (2.4 GHz) Loosing AirPort Connectivity

    I have a MacBook Pro 15 (2.4GHz) connecting via AirPort to an AirPort Extreme base station. At least once a day, randomly, my MacBook will drop the wireless connection, and then start prompting me for a password to reconnect. If I reboot the machine,