Welcome!

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

Reply
Developer
Developer
arv
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.

 

Thanks.

 

 

--
"Give kudos (star) if you feel response is helpful"
Please use plain text.
Administrator
MSohm
Posts: 14,429
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
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 

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800451/800563/What_Is...

 

 

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

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800698/How_To_...

 

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 4.5.0.47 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
Please use plain text.
Developer
Developer
arv
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.

thanks.

--
"Give kudos (star) if you feel response is helpful"
Please use plain text.