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

NEW 1000W Power Supply AC100-240V to 72V DC Regulated Switching Power Supply
$185.0
NEW 1000W Power Supply AC100-240V to 72V DC Regulated Switching Power Supply  pictureNEW 500W 300V DC Output Regulated Switching Power Supply CNC WITH CE
$165.0
NEW 500W 300V DC Output Regulated Switching Power Supply CNC WITH CE pictureNEW 500W 180V DC 2.7A Output Regulated Switching Power Supply CNC WITH CE
$95.0
NEW 500W 180V DC 2.7A Output Regulated Switching Power Supply CNC WITH CE pictureIsuzu Thermal Switch IP305A 70 degree Celsius x 2
$10.0
Isuzu Thermal Switch IP305A 70 degree Celsius x 2 pictureTCRT5000 Barrier Line Track sensor Infrared Reflective Photoelectric Switch SHPF
$1.29
TCRT5000 Barrier Line Track sensor Infrared Reflective Photoelectric Switch SHPF picture






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