BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 06-13-2007, 05:25 AM   #1 (permalink)
Thumbs Must Hurt
 
Join Date: May 2007
Location: berlin, germany
Model: 8310
PIN: N/A
Carrier: vodafone
Posts: 163
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default display image from email attachment

Please Login to Remove!

hi,
i've got an email with an image as attachment in my inbox folder.
now i want to show this image in my application.

how can i draw it into a BitmapField?

thanks hibbert
__________________
My English is so bad, that makes me nobody so quickly after
Offline  
Old 06-13-2007, 09:36 AM   #2 (permalink)
Thumbs Must Hurt
 
Join Date: May 2007
Location: berlin, germany
Model: 8310
PIN: N/A
Carrier: vodafone
Posts: 163
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

ok, this is my code at the moment:
Code:
public void messagesAdded(FolderEvent e) {
        System.out.println("new message arrived");
        Message m = e.getMessage();
        m.setFlag(Message.Flag.OPENED, true); // email als gelesen markieren...
        try{
        Multipart cont;
        cont = (Multipart)m.getContent();
        System.out.println("# attachments: " + cont.getCount());
        
        UnsupportedAttachmentPart bp;
        
        bp = (UnsupportedAttachmentPart)cont.getBodyPart(1);
        System.out.println("filename: " + bp.getName());                                
        System.out.println("size: " + bp.getSize()); 
    } catch (Exception ex) {System.out.println("Error while getting attachment information...");}
    } // message added
and this is what the debugger shows:
Quote:
Originally Posted by Debugger
new message arrived
# attachments: 2
filename: wiese.png
size: 0
Sounds good... but why is the size of the image 0 ? an how can i display the image? (paint it in an existing graphic...)

thanks alot.

hibbert
__________________
My English is so bad, that makes me nobody so quickly after
Offline  
Old 06-14-2007, 03:56 AM   #3 (permalink)
Thumbs Must Hurt
 
Join Date: May 2007
Location: berlin, germany
Model: 8310
PIN: N/A
Carrier: vodafone
Posts: 163
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

sorry for spamming, but it's really importent that i can read this f*ck'n attachment image.

now i tried this one here:
Code:
 public void messagesAdded(FolderEvent e) {
        System.out.println("new message arrived");
        Message m = e.getMessage();
        m.setFlag(Message.Flag.OPENED, true); // email als gelesen markieren...
        try{
        Multipart cont;
        cont = (Multipart)m.getContent();
        System.out.println("# attachments: " + cont.getCount());
        
        
        
        bp = (UnsupportedAttachmentPart)cont.getBodyPart(1);
        System.out.println("filename: " + bp.getName());                                
        System.out.println("size: " + bp.getSize()); 
        
        
        MainScreen Test = new MainScreen();
        Test.add(new LabelField("This should be the content of the attachment..."+bp.getName()));
        System.out.println("...");
        Test.add(new RichTextField(new String((byte[])bp.getContent())));
        pushScreen(Test);
        
        
        newMail = true;
        } catch (Exception ex) {System.out.println("Error while getting attachment information..."+ex);}
    } // message added
but i get an exception...
Quote:
new message arrived
# attachments: 2
filename: wiese.png
size: 0
...
Error while getting attachment information...java.lang.NullPointerException
i don't know why this stupid error appears... can anyone help me, please?

hibbert
__________________
My English is so bad, that makes me nobody so quickly after
Offline  
Old 06-18-2007, 04:09 AM   #4 (permalink)
Thumbs Must Hurt
 
Join Date: May 2007
Location: berlin, germany
Model: 8310
PIN: N/A
Carrier: vodafone
Posts: 163
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

*push*
__________________
My English is so bad, that makes me nobody so quickly after
Offline  
Old 11-18-2007, 05:13 PM   #5 (permalink)
New Member
 
Join Date: Nov 2007
Model: 8830
PIN: N/A
Carrier: verizon
Posts: 2
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Did you ever figure out how to receive an image attachment from an email? I'm also trying to do this, but nothing is working so far. I've tried to register my app as an attachment handler for image files, and that has allowed me to work with the attachments as SupportedAttachmentParts, but I still cannot get any data from the server.

Has anyone been able to pull image files off of messages? I'm assuming that we should be able to do this...
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





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