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 HP Proliant DL380 Gen4/ML370 Server Intel Xeon Processor 311584-B21
$19.79
New HP Proliant DL380 Gen4/ML370 Server Intel Xeon Processor 311584-B21 picture2x Intel Xeon Match Pair E5620 Quad Core CPU 2.40Ghz 12M 5.86 GT/s SLBV4 LGA1366
$19.95
2x Intel Xeon Match Pair E5620 Quad Core CPU 2.40Ghz 12M 5.86 GT/s SLBV4 LGA1366 picture2x Intel Xeon X5650 Six Core Processor SLBV3 2.66 GHz 12MB 6.4 CPU
$49.95
2x Intel Xeon X5650 Six Core Processor SLBV3 2.66 GHz 12MB 6.4 CPU pictureNASUNI FILER NF-400 DELL POWEREDGE R620 7.2 TB 32GB RAM Intel Xeon E5-2609 X 2
$2995.0
NASUNI FILER NF-400 DELL POWEREDGE R620 7.2 TB 32GB RAM Intel Xeon E5-2609 X 2  picture1 pc used Intel S1200BTL Server Board 1155 pin & intel Xeon processor
$79.99
1 pc used Intel S1200BTL Server Board 1155 pin & intel Xeon processor picture






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