Q:

javamail fetch mail pop3 android

I want to fetch emails in android by using javamail. 
but I encountered some problems. 
in POP3, if I want to fetch the content of a certain mail, the javamail will download all the content of the mail including the attachments.  if the attachments are large enough, the android program will throw  oom exception.  But I tried in IMAP protocal, it only fetch the skeleton of the content first and even if there are some large attachments, it works well. 
so, how could I fetch the content of a certain email using pop3 protocal when there are large attachment in the email? 
following codes work well with imap, but not with pop3. 
public void getContent(Part part) throws Exception {
    String contentType = part.getContentType();
    int nameindex = contentType.indexOf("name");
    boolean conname = false;
    if (nameindex ! = -1)
        conname = true;
    if (part.isMimeType("text/plain") && ! conname) {
        bodytext.append((String) part.getContent());
    } else if (part.isMimeType("text/html") && ! conname) {
        String html = (String) part.getContent();
        Spanned plainText = Html.fromHtml(html);
        bodytext.append(plainText);
    } else if (part.isMimeType("multipart/*")) {
        Multipart multipart = (Multipart) part.getContent();
        int counts = multipart.getCount();
        for (int i = 0; i < counts; i++) {
            BodyPart mpart = multipart.getBodyPart(i);
            Log.d("type,"," "+ i+mpart.getContentType());

            String disposition = mpart.getDisposition();
            if ((disposition ! = null)
                    && ((disposition.equals(Part. ATTACHMENT)) || (disposition
                            .equals(Part. INLINE))))
                continue;
            String contype = mpart.getContentType();
            if(contype.toLowerCase().indexOf("application")!=-1||contype.toLowerCase().indexOf("name")!=-1)
                continue;

            getContent(multipart.getBodyPart(i));
        }
    } else if (part.isMimeType("message/rfc822")) {
        getContent((Part) part.getContent());
    }
}

A:

I do not know the specifics of JavaMail, however:
IMAP provides methods in it's protocol for downloading MIME Parts of a message, allowing the message to be picked apart on the server and downloaded in parts. 
POP3s basic protocol only has support for downloading the entire message.   With the optional TOP extension, it will allow you to download the first n lines of a message. 
If JavaMail has specific extensions to stream the download of a message to disk (rather than all in memory), that should allow you to get around your Out Of Memory error.