Open A Message - Blackberry JAVA DEVELOPMENT ENVIRONMENT - - DEVICE APPLICATIONS INTEGRATION - DEVELOPMENT GUIDE Integration Manual

Blackberry device applications integration guide
Table of Contents

Advertisement

BlackBerry Device Applications Integration Guide
Task
Get more of a message.

Open a message

1.
Retrieve the message store and the folder that contains the message.
Store store = Session.waitForDefaultSession.getStore();
Folder folder = Store.getFolder("SampleFolder");
2. Retrieve the message objects from the folder. Iterate through the array and retrieve information, such as the
sender and subject, to display to the BlackBerry® device user.
Message[] msgs = folder.getMessages();
3. When a BlackBerry device user selects a message from the list, invoke methods on the
retrieve the appropriate fields and body contents to display to the BlackBerry device user.
Message msg = msgs[0]; // Retrieve the first message.
Address[] recipients = msg.getRecipients(Message.RecipientType.TO)
Date sent = msg.getSentDate();
Address from = msg.getFrom();
String subject = msg.getSubject();
Object o = msg.getContent();
// Verify that the message is not multipart.
if ( o instanceof String ) {
String body = (String)o;} //...
4. Invoke
getBodyText()
contain plain text, the method returns null.
16
Steps
By default, the first section of a message (typically about 2 KB) is sent to the BlackBerry® device.
1. Create an instance of a subclass of the
TextBodyPart tb = new TextBodyPart(new MultiPart());
2. To determine if more data for a body part is available on the server, invoke
3. To determine if the BlackBerry device user made a request for more data, invoke
tb.moreRequestSent()
Transport
4. To obtain a
object in a variable of type
Transport trans = Session.getTransport();
5. To request more of a message, invoke
second parameter of
section of the body part (false) or all remaining sections of the body part (true).
if (( tb.hasMore() ) && (! tb.moreRequestSent()) {trans.more(tb,
true);}
on a message to retrieve the plain text contents as a
BodyPart
abstract class.
.
Session.getTransport()
object, invoke
Transport
.
trans.more(BodyPart bp, boolean reqAll)
more()
is a Boolean value that specifies whether to retrieve only the next
tb.hasMore()
and store the returned
Message
object to
String
. If the message does not
.
. The

Advertisement

Table of Contents
loading

This manual is also suitable for:

Java development environment 4.6.0

Table of Contents