Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 28
Registered: ‎12-18-2008
My Device: Not Specified

email an image as an attachment...

I need to attach an image to an email and send. The following is the part of my code i used to read the image from the device storage and add to the attachment. But it's not working..  

 

FileConnection fconn = (FileConnection)Connector.open("file:///SDCard/BlackBerry/pictures/IMG00017.jpg");
                        input = fconn.openInputStream();
                        buffer = new DataBuffer();
                        byte[] temp = new byte[1024];
                        
                        for( ;; ) {
                            int bytesRead = input.read( temp );
                            if( bytesRead == -1 ) {
                            break;
                            }
                            buffer.write( temp, 0, bytesRead );
                            }
                            input.close();
                            fconn.close();
                            
                      SupportedAttachmentPart sap = new SupportedAttachmentPart(mp,".jpg","file.jpg",buffer.getArray());

 

Can anyone correct my code if there is any problem? Or can you suggest another solution?

 

Thanks..

Developer
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: email an image as an attachment...

Hi,

Check with size of image, Some devices have problem reading a bigger image.

 

Try sending a small image.

 

Check you getting any exception and you can use device debugger too for tracing.

 

Tnx.


Use Search. "Accept Solution" If the problem is resolved.