17
3: Work with a message
Retrieve the body of a message without an attachment
1.
Invoke
Message.getContent()
.
Object obj=message.getContent();
2.
If the content of the message is a
Multipart
object, cast the message content as a
Multipart
object.
if(obj instanceof Multipart){
Multipart mp=(Multipart)obj;
}
3. If the content of the message is of type
multipart/alternative
, iterate through the
BodyPart
objects in
the
Multipart
object, storing each reference to a
BodyPart
object in a
BodyPart
variable.
if(mp.getContentType().equals(ContentType.MULTIPART_ALTERNATIVE){
for(int i=0;i<mp.getCount();i++){
BodyPart bp=mp.getBodyPart(i);
4. If a
BodyPart
object is of type
MimeBodyPart
, store the content type of the
BodyPart
object in a
String
variable.
if(bp instanceof MimeBodyPart){
String type=bp.getcontentType();
5. Check if the content type of the
BodyPart
object is text_html.
if(type.equals(ContentType.TYPE_TEXT_HTML_STRING){
6. Check if the content type of the
BodyPart
object is
TextBodyPart
.
}else if(bp instanceof TextBodyPart){
Retrieve the body of a message with an attachment
1.
Invoke
Message.getContent()
.
Object obj=message.getContent();
2.
Cast the message content as a
Multipart
object.
Multipart mp=(Multipart)obj;
3. If the content of the message is of type
multipart/mixed
, iterate through
BodyPart
objects in the
Multipart
object, storing each reference to a
BodyPart
object in a
BodyPart
variable.
if(mp.getContentType().equals(ContentType.MULTIPART_MIXED){
for(int i=0;i<mp.getCount();i++){
BodyPart bp = mp.getBodyPart(i);
Содержание JAVA DEVELOPMENT ENVIRONMENT - - DEVICE APPLICATIONS INTEGRATION - DEVELOPMENT GUIDE
Страница 1: ...BlackBerry Java Development Environment Version 4 6 0 BlackBerry Device Applications Integration Guide...
Страница 4: ......
Страница 7: ......
Страница 10: ...10 BlackBerry Device Applications Integration Guide...
Страница 12: ...12 BlackBerry Device Applications Integration Guide...
Страница 50: ...50 BlackBerry Device Applications Integration Guide...
Страница 56: ...56 BlackBerry Device Applications Integration Guide...
Страница 65: ......
Страница 66: ...2008 Research In Motion Limited Published in Canada...