Troubleshooting guide
158
BlackBerry Java Development Environment Development Guide
Forward a message
Work with folders
1. Invoke getStore() on the default session.
Store store = Session.waitForDefaultSession().getStore();
2. Complete any of the following tasks:
Task Steps
Create a message object. >Invoke forward() on a Message object. The subject line of a forwarded message is set
automatically to FW:<
original_subject>.
Message fwdmsg = msg.forward();
Add the recipients. 1. Create an array of addresses.
Address toList[] = new Address[1];
2. Invoke addRecipients(int, Address[]).
toList[0]= new Address("aisha.wahl@blackberry.com", "Katie Laird");
fwdmsg.addRecipients(Message.RecipientType.TO, toList);
Specify that the message content
appears before the original message.
>Invoke setContent(String).
try {
fwdmsg.setContent("This is a forwarded message.");
} catch(MessagingException e) {
System.out.println(e.getMessage());
}
Send the message. >Invoke send(Message).
try {
Transport.send(fwdmsg);
} catch(MessagingException e) {
System.out.println(e.getMessage());
}
Task Steps
Open a folder view. 1. Invoke store.list() to retrieve a list of folders.
Store store = null;
store = Session.waitForDefaultSession().getStore();
Folder[] folders = store.list();
2. Invoke invokeApplication()using the APP_TYPE_MESSAGES constant parameter and a new
MessageArguments object that uses a folder from the list of folders as a parameter.
Invoke.invokeApplication(Invoke.APP_TYPE_MESSAGES, new MessageArguments(
folders[0]));
List the folders in a mailbox
store.
>Invoke Store.list().
Folder[] folders = store.list();
Retrieve an array of folders by
type.
>Invoke list(int). Provide the folder type as a parameter to this method.
Folder[] folders = store.lst(INBOX);
Folder inbox = folders[0];