23
3: Work with folders
Forward a message
Work with folders
1.
Invoke
getStore()
on the default session.
Store store = Session.waitForDefaultSession().getStore();
Task
Steps
Create a message object.
>
Invoke
forward()
on an existing
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("[email protected]", "Clyde Warren");
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.
1.
Invoke
Session.getTransport()
and store the returned object in a variable of type
Transport
. The
Transport
object represents the messaging transport protocol.
Transport trans = Session.getTransport();
2. Invoke
trans.send(Message)
.
try {
trans.send(fwdmsg);
} catch(MessagingException e) {
System.out.println(e.getMessage());
}
Summary of Contents for JAVA DEVELOPMENT ENVIRONMENT - - DEVICE APPLICATIONS INTEGRATION - DEVELOPMENT GUIDE
Page 4: ......
Page 7: ......
Page 10: ...10 BlackBerry Device Applications Integration Guide...
Page 12: ...12 BlackBerry Device Applications Integration Guide...
Page 50: ...50 BlackBerry Device Applications Integration Guide...
Page 56: ...56 BlackBerry Device Applications Integration Guide...
Page 65: ......
Page 66: ...2008 Research In Motion Limited Published in Canada...