Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Posts: 122
Registered: ‎08-11-2008
My Device: 9700
My Carrier: XL
Accepted Solution

How to programmatically retrieve attachment?

Halo All,


I'm a new programmer of Blackberry Application.


i create a program that automatically read from Store, using FolderListener.

when i got event from FolderEvent, i got Message which is instanceof Multipart.


I create BodyPart from Multipart, to access my attachment. (bodypart index number 1)

when I check bodypart.hasMore() it's return true.

I do Transport.more(bodypart, true);

I create a loop to check it bodypart.hasMore(), until 2 minutes it still true

(found attachment on server).


why I can't complete my message?

(the bodypart.hasMore() never return false).


is there any how to to get attachment from Message (mail api)?


my attachment is a binary with base64 format, it size only 100 Bytes.

I don't have any idea, is my attachment included on (2K bytes of first) message?



Any help would be much appreciated.





"Give kudos (star) if you feel response is helpful"
BlackBerry Development Advisor
Posts: 15,211
Registered: ‎07-09-2008
My Device: BlackBerry Passport
My Carrier: Bell

Re: How to pragmatically retrieve attachment?

Please have a look at this sample.


What Is - Delivering attachment contents to a BlackBerry device
Article Number: DB-00475 




BlackBerry handheld software version 4.5.0 introduced the ability to access attachments without using an AttachmentHandler.  The following link explains this.


How To - Access HTML email messages
Article Number: DB-00666



It demonstrates getting the HTML or text portions of an email message, but the same principles can apply to attachments.  Note that this requires a BlackBerry Enterprise Server or BlackBerry Internet Service account.  The ESS and MDS Simulators do not support HTML email delivery.


There is also an issue in a few early releases of version 4.5.0 that prevents you from requesting more of an attachment (using the second method).  This is fixed in BlackBerry handheld software version and higher.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Posts: 122
Registered: ‎08-11-2008
My Device: 9700
My Carrier: XL

Re: How to pragmatically retrieve attachment?

Thank you Mark,

the problem now solved.


solution of my problem is change the AttachmentHandler to listen

attachment with content-type: octet-stream.

i don't know why, the blackberry device cannot recognize

that i change my content-type to my own string.


your links are awesome.


"Give kudos (star) if you feel response is helpful"