0

I can access Hotmail with Javamail.jar on Android. I want to receive a mail's attachment with Hotmail, this code is working for Gmail but with Hotmail is not working. Why it is not filling the disposition, so "dosyaIsmiEkDurumu" is not filling and is falling into the catch because of that.

Is there other code samples for access attachments on Hotmail, or why am I doing wrong with this code?

public void EkDosyaIsim(Part part) throws IOException,
            MessagingException {

        if (part.isMimeType("multipart/*")) {
            Multipart mp = (Multipart) part.getContent();
            for (int i = 0; i < mp.getCount(); i++) {
                System.out.println("64 : [" + mp.getCount() + "] 个/n");
                BodyPart mpart = mp.getBodyPart(i);
                String disposition = mpart.getDisposition();
                if ((disposition != null)
                        && ((disposition.equals("ATTACHMENT")) || (disposition
                                .equals("INLINE")))) {
                    dosyaIsmiEkDurumu = mpart.getFileName();
                    if(dosyaIsmiEkDurumu != null)
                    {
                        dosyaIsmiDizi[k] = dosyaIsmiEkDurumu;
                        k++;
                    }
                    if (dosyaIsmiEkDurumu.toLowerCase().indexOf("gb2312") != -1) {
                        dosyaIsmiEkDurumu = MimeUtility.decodeText(dosyaIsmiEkDurumu);
                    }
                } else if (mpart.isMimeType("multipart/*")) {
                    EkDosyaIsim(mpart);
                } else 
                {
                    if ((dosyaIsmiEkDurumu != null)
                            && (dosyaIsmiEkDurumu.toLowerCase().indexOf("GB2312") != -1)) {
                        dosyaIsmiEkDurumu = MimeUtility.decodeText(dosyaIsmiEkDurumu);
                    }
                }
            }
        } else if (part.isMimeType("message/rfc822")) 
        {
            EkDosyaIsim((Part) part.getContent());
        }
    }
halfer
  • 19,824
  • 17
  • 99
  • 186
Merve Gül
  • 1,377
  • 6
  • 23
  • 40

1 Answers1

0

The disposition is "advice", it's not guaranteed to be there even in messages that have attachments. See the JavaMail FAQ for more information on handling messages with attachments.

Bill Shannon
  • 29,579
  • 6
  • 38
  • 40