05-25-2009 05:51 PM
I'm very very very new to BB java development and need to have this task urgently done.
I've successfully sent texted-based emails and MMS, but have difficulties to send them with attachments. Let's say, I took a photo named example.jpg, stored at default location store/home/user/pictures/... I wish to send it with an email and with MMS. How do I add it to the msg object and sent it along. Thank you!
Here is my code I've done so far.:
Store store = Session.getDefaultInstance().getStore(); //Get the Store from the default mail Session. Folder[] folders = store.list(Folder.SENT); //retrieve the sent folder Folder sentfolder = folders[0]; Message msg = new Message(sentfolder); msg.addRecipients(Message.RecipientType.TO, addresses); msg.setSubject("Bla Bla Bla"); msg.setContent(body);
And for MMS:
// opens connection MessageConnection conn = (MessageConnection) Connector.open(addr); // prepares multipart message MultipartMessage msg = (MultipartMessage)conn.newMessage(MessageConnectio
n.MULTIPART_MESSAGE); //set message msg.setAddress(addr); msg.setSubject(subject); //set parts byte[] bodyBin = body.getBytes(MMS_TEXT_ENC); MessagePart bodyPart = new MessagePart(bodyBin, 0, bodyBin.length, "text/plain", "id1", "contentLocation", MMS_TEXT_ENC); msg.addMessagePart(bodyPart);
05-26-2009 02:30 AM
Hi Badgrant,
For attachment for emails, check following link. Also if you do a search you will find some threads regarding this.
And note that image attachments will not work on Simulator with ESS. Only text would be sent as per my experience. I have tried on device with BIS and attachments works fine on device.
For MMS, even i was trying for MMS but still no luck. I was not even able to send text. Only Subject is visible on recepient's handset. You can check following thread.
http://supportforums.blackberry.com/rim/board/mess
Thanks,
Sandeep
------------------------
If your problem gets solved, please mark the thread as "Accepted Solution". And click on Kudos to thank the user who helps you.
05-26-2009 10:09 AM