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

Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.

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,884
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
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.
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"