I've been trying for days to get an email attachment.
My main problem is that the second part of my multipart, the attachment, is always of the type UnsupportedAttachment.
I retrieve the mail using a folderlistener.
on the message i use the following code:
Code:
Object c = message.getContent();
if (c instanceof Multipart) {
Multipart m = (Multipart)c;
if (m.getCount()>0){
BodyPart bp = m.getBodyPart(1);
System.out.println("bp class: "+bp.getClass());
if (bp instanceof UnsupportedAttachmentPart){
UnsupportedAttachmentPart s = (UnsupportedAttachmentPart) m.getBodyPart(1);
System.out.println("name: "+s.getName()+" size: "+s.getSize());
}
}
} as output i get:
Code:
bp class: class net.rim.blackberry.api.mail.UnsupportedAttachmentPart
name: ess.png size: 0
taking a look at UnsupportedAttachment that is not surprising as getSize() always returns 0.
Question is: How do i get an attachment then? Any way for my second bodypart not being of the UnsupportedAttachment-type?
I tested this on the real device, not only the simulator. Even attachments i can view are considered Unsupported in my code.