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

New Contributor
Posts: 5
Registered: ‎05-11-2011
My Device: 8520
My Carrier: orange

sending a pin message with attached

[ Edited ]


I'm trying to send a photo programmatically pin but the message arrives with an attachment that can not be opened: s.

when I try to view the attachment tells me that the system is not valid.

here is my code to see if I have something wrong ...


   public boolean sendMail(String To, String PIN, String Subject, String Message, Bitmap postal) {
        // TODO Auto-generated method stub

        PNGEncodedImage image = PNGEncodedImage.encode(postal);
        byte[] data = image.getData();
        Multipart multipart = new Multipart();
        SupportedAttachmentPart attach = new SupportedAttachmentPart( multipart,
                                                                    "image/jpeg", "Postal.jpg", data);
        Store store = Session.getDefaultInstance().getStore();

        //retrieve the sent folder
        Folder[] folders = store.list(Folder.SENT);
        Folder sentfolder = folders[0];

        //create a new message and store it in the sent folder
        Message msg = new Message(sentfolder);
        try {
            PINAddress recipients = new PINAddress(PIN, To);
            Address[] addresses   = {recipients};

             //add the recipient list to the message
             msg.addRecipients(net.rim.blackberry.api.mail.Message.RecipientType.TO, addresses);
             //set a subject for the message
             //sets the body of the message
             //send the message
             return true;
        catch (MessagingException me)

        return false;


PS: when I send the same email photo the photo is displayed well. : (

sorry for my English.
  translated by google translator.