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
dx22
Posts: 402
Registered: ‎11-26-2010
Accepted Solution

Open email application with predefined file attachment

Is it possible to open the email app and specify path to a file on the file system as attachment? I need to do this from my app.

 

I know I can open the app with predefined body, subject etc. but I want to know about the file attachments.

 

I also know that I can do this programatically from my app but I want to take advantage of the nice UI the mail app provides instead of implementing custom forms from my app.

----------------------------------------------------------------------
Press the button to give kudos if I helped you :smileyhappy:
Please use plain text.
Administrator
MSohm
Posts: 14,064
Registered: ‎07-09-2008
My Carrier: Bell

Re: Open email application with predefined file attachment

No, this is not supported.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Trusted Contributor
omar123456789
Posts: 103
Registered: ‎11-07-2010

Re: Open email application with predefined file attachment

you can make this,

 

please try this code.

 

    PNGEncodedImage encoder = PNGEncodedImage.encode(b);
                byte[] stream = encoder.getData();

                String messageData = "See attachment: " + "test.png";

                if (stream == null || stream.length == 0) {

                }
                String mmtype = MIMETypeAssociations.getMIMEType("icon.png");
                Dialog.alert(mmtype);

                mp = new Multipart();
                SupportedAttachmentPart sap = new SupportedAttachmentPart(mp,
                        mmtype, "icon.png", stream);

                TextBodyPart tbp = new TextBodyPart(mp, messageData);
                mp.addBodyPart(tbp);
                mp.addBodyPart(sap);
                Folder folders[] = Session.getDefaultInstance().getStore()
                        .list(Folder.SENT);
                message = new Message(folders[0]);
                Address[] toAdds = new Address[1];
                try {
                    toAdds[0] = new Address("omar.hassan@asgatech.com", "omar");
                    message.addRecipients(Message.RecipientType.TO, toAdds);
                    message.setContent(mp);
                    message.setSubject("Message with attachment " + "icon.png"
                            + ".");

                    Invoke.invokeApplication(Invoke.APP_TYPE_MESSAGES,
                            new MessageArguments(message));

                } catch (AddressException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (MessagingException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

Please use plain text.
Administrator
MSohm
Posts: 14,064
Registered: ‎07-09-2008
My Carrier: Bell

Re: Open email application with predefined file attachment

Right, you can create a message to send with an attachment and use that when invoking the messages application.  

 

I understood the requirement as opening an email message and view its attachment in the Messages app.  Sorry if I misunderstood.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Developer
dx22
Posts: 402
Registered: ‎11-26-2010

Re: Open email application with predefined file attachment

@MSohm you understood me correctly - I wanted to take advantage of everything the default mail app offers and your first reply was what I needed as information.
I wanted to avoid creating custom forms for email sending.
I ended up using @omar123456789 approach though and it seems to work well.
----------------------------------------------------------------------
Press the button to give kudos if I helped you :smileyhappy:
Please use plain text.