BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 12-14-2007, 05:12 AM   #1 (permalink)
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default How to get an email attachment?

Please Login to Remove!

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.
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 12-14-2007, 10:00 AM   #2 (permalink)
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

seems solved.

i had to add an attachmenthandler for the kind of attachment as well as prefixing the file with x-rimdevice. wow, good end of the week!
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 12-14-2007, 11:33 AM   #3 (permalink)
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

not so good.

SupportedAttachment.getContent().getClass() returns [B
byte[] b = SupportedAttachment.getContent();
b.length is 0...

SupportedAttachment.writeTo() does not work either
__________________
java developer, Devinto, hamburg/germany
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

100pcs 25V 33uF 25V Panasonic SU series 5x11mm High Quality Capacitor
$5.99
100pcs 25V 33uF 25V Panasonic SU series 5x11mm High Quality Capacitor picture50pcs 22uF 16V22UF 6X7 SUNCON (SANYO) SWN Bi-polar Capacitor
$3.19
50pcs 22uF 16V22UF 6X7 SUNCON (SANYO) SWN Bi-polar Capacitor picture500pcs 25V 100uF 25V G-LUXON SS 8x7mm Electrolytic Capacitor
$25.49
500pcs 25V 100uF 25V G-LUXON SS 8x7mm Electrolytic Capacitor picture3pcs 470uF 200V Japan Nichicon GU 22x35mm 200V470uF Snap-in Capacitor
$5.99
3pcs 470uF 200V Japan Nichicon GU 22x35mm 200V470uF Snap-in Capacitor pictureLot Of 6 Mil Grade Silver Feed Though Caps Capacitors .0035uf
$7.5
Lot Of 6 Mil Grade Silver Feed Though Caps Capacitors .0035uf picture






Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.