Giter VIP home page Giter VIP logo

Comments (4)

GoogleCodeExporter avatar GoogleCodeExporter commented on August 22, 2024
Sorry..wrong typing.
i mean: anyone help??

Original comment by [email protected] on 27 Mar 2010 at 5:11

from javamail-android.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 22, 2024
Here is my code for saving the attachment, but it is IMAP Based, don't know if 
it's 
different for POP3.  I got the original example from a Sun Javamail example.

String folder = getAttachmentFolderForMessage(getMessageUID(msg));      

if(msg.isMimeType("multipart/*"))
{   //It's a a multipart so go through the parts and find what looks like the 
attachments
    Multipart mp = (Multipart)msg.getContent();
    int partCount = mp.getCount();
    Part curtPart;
    String curPartDisposition;
    String filename;
    File file;
    for (int i = 0; i < partCount; i++)
    {
    curtPart = mp.getBodyPart(1);
    curPartDisposition = curtPart.getDisposition();
        // many mailers don't include a Content-Disposition
        if (curPartDisposition == null || curPartDisposition.equalsIgnoreCase
(Part.ATTACHMENT)) 
        {
        filename = curtPart.getFileName();
            if (filename == null || filename.length() == 0)
                filename = "Attachment" + i;
            filename = folder + filename;
            try 
            {
                file = new File(filename);
                ((MimeBodyPart)curtPart).saveFile(file);
                Log.d(LogTag,"Saved the attachment "+i+" to the 
following filename ["+filename+"].");
            } 
            catch (IOException ex) 
            {
                Log.e(LogTag,"Caught an exception trying to save an 
attachment to the filename ["+filename+"].",ex);
                throw new IMAPException("Unable to save the attachment 
to a file. "+ex.getMessage());
            }
        }
    }
}

Original comment by [email protected] on 31 Mar 2010 at 1:17

from javamail-android.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 22, 2024
Thank you for your response..
but the statement: Multipart mp = (Multipart)msg.getContent(); 
cannot work on this javamail-android's jar, 
it will throws exceptions: 
SharedByteArrayInputStream cannot be cast to javax.mail.Multipart

Original comment by [email protected] on 31 Mar 2010 at 3:00

from javamail-android.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 22, 2024
I don't know the full answer but from what I see in the comments and the code 
this 
is a difference in the mail message you are getting from your mail server.  It 
might 
also have to do with POP3 over IMAP, cause the above code defentily does work 
for 
me.  I would check out the SharedByteArrayInputStream and see if you can read 
from 
it to get the attachment.  Maybe also check the Sun site for javamail and 
checkout 
the FAQ and or the demo's, they have some good code examples.

Original comment by [email protected] on 31 Mar 2010 at 3:37

from javamail-android.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.