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
New Contributor
Posts: 5
Registered: ‎08-30-2010
My Device: Not Specified

Create Message with embedded image

Hello,

 

I'm not sure if what I'm trying to do is possible, but I figured this would be a good spot for help.  Here's what I'm trying to do:

 

-App receives push message

-App goes to server to retrieve some extended data regarding the message

-App then creates a Message object, and places it in the users Inbox with data received from push/server

 

I have all three steps working, however my next step is to embed an image into this Message that is in the user's inbox.  Is this possible?  So far, I've been able to include the image as an attachment, but I'd like the image to automatically display as if it were embedded in an HTML email.

 

Any help is appreciated.

 

Thanks!

Dan

Developer
Posts: 723
Registered: ‎03-12-2009
My Device: Playbook

Re: Create Message with embedded image

You can try to embed HTML into your message.

New Contributor
Posts: 5
Registered: ‎08-30-2010
My Device: Not Specified

Re: Create Message with embedded image

How would I display HTML in the message?  I've tried doing something like:

 

message.setContent("<html>...</html>")

 

but it just displays all the HTML as text in the message body.  Any examples are appreciated.

 

Dan

Developer
Posts: 723
Registered: ‎03-12-2009
My Device: Playbook

Re: Create Message with embedded image

New Contributor
Posts: 5
Registered: ‎08-30-2010
My Device: Not Specified

Re: Create Message with embedded image

Sorry, maybe I wasn't clear.  My device already has HTML e-mails enabled - I receive them all the time.  However, if I create a Message in the Java code, the HTML code ends up displaying as text rather than formatted HTML.

 

So my code would be something like:

 

 

Message message = new Message(mInboxFolder);
message.setFrom(new Address("1234", "Address Here")); 
message.setSubject("Push Alert");
message.setContent("<html><body><a href=\"test.html\">TEST LINK</a></body></html>");
message.setInbound(true);
message.setStatus(Message.Status.RX_RECEIVED, Message.Status.TX_DELIVERED);
mInboxFolder.appendMessage(message);

 

 

 

Now when I open the message that was placed in my Inbox on my device, the body is literally just the HTML code verbatim:

<html><body><a href=\"test.html\">TEST LINK</a></body></html>

 

So, if my device already has HTML messages enabled, how can I create an HTML message that will display properly via Java code?

 

Thanks,

Dan

Developer
Posts: 1,305
Registered: ‎01-21-2009
My Device: Not Specified

Re: Create Message with embedded image

Try adding

 

message.setHeader(HEADER_CONTENT_TYPE, CONTENT_TYPE_TEXT_HTML);

(Those constants are defined in interface HttpProtocolConstants.)




Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.
New Contributor
Posts: 5
Registered: ‎08-30-2010
My Device: Not Specified

Re: Create Message with embedded image

That didn't work; it's still just displaying the HTML code as the message Smiley Sad

 

Any other ideas?

New Contributor
Posts: 5
Registered: ‎08-30-2010
My Device: Not Specified

Re: Create Message with embedded image

Does anyone know how to embed HTML into a Message that will be placed into a user's inbox?  So far, I can only get the HTML code to display as the actual message body.

Highlighted
Regular Contributor
Posts: 73
Registered: ‎12-30-2011
My Device: All devices
My Carrier: RIM

Re: Create Message with embedded image

I want to do this same , please help any one its too urgent for me

Thanks

Mohd Farhan