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

35Pcs 2SD371/ D371 Audio Power Transistor TO-3 NR
$24.99
35Pcs 2SD371/ D371 Audio Power Transistor TO-3 NR picture35Pcs 2SB531/ B531 Audio Power Transistor TO-3 NR
$24.99
35Pcs 2SB531/ B531 Audio Power Transistor TO-3 NR pictureNTE2302 HORIZONTAL OUTPUT NPN TRANSISTOR TO3PJ REPL ECG2302
$4.99
NTE2302 HORIZONTAL OUTPUT NPN TRANSISTOR TO3PJ REPL ECG2302 pictureReplacemen Mitsubishi GT1585-VNBA-C Touch Screen Panel Glass Touchpad
$79.99
Replacemen Mitsubishi GT1585-VNBA-C Touch Screen Panel Glass Touchpad pictureReplacemen Mitsubishi GT1585-STBA GT1585-STBD Touch Screen Panel Glass
$78.99
Replacemen Mitsubishi GT1585-STBA GT1585-STBD Touch Screen Panel Glass picture






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