04-12-2012 10:53 AM
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.
button to give kudos if I helped you Solved! Go to Solution.
04-16-2012 09:43 AM
No, this is not supported.
04-17-2012 11:11 AM
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();
}
04-17-2012 01:51 PM
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.
04-18-2012 03:10 AM
button to give kudos if I helped you