18
BlackBerry Device Applications Integration Guide
4. If the
BodyPart
object is of type
MimeBodyPart
, check if the content type of the
Multipart
object is
MULTIPART_ALTERNATIVE.
if(bp instanceof MimeBodyPart){
MimeBodyPart mbp=(MimeBodyPart)bp;
Multipart mp=(Multipart)mbp.getContent();
if(mp.getcontentType().equals(ContentType.MULTIPART_ALTERNATIVE){
5. If the content type of the
Multipart
object is MULTIPART_ALTERNATIVE, store a reference to a
BodyPart
object in a
BodyPart
variable.
BodyPart xp=mp.getBodyPart(i);
6. If a
BodyPart
object is of type
MimeBodyPart
, store the content type of the
BodyPart
object in a
String
variable.
if(xp instanceof MimeBodyPart){
String type=xp.getcontentType();
7.
Check if the content type of the
BodyPart
object is text_html.
if(type.equals(ContentType.TYPE_TEXT_HTML_STRING){
// HTML text
}
8. Check if the content type of the
BodyPart
is
TextBodyPart
.
}else if(xp instanceof TextBodyPart){
// Plain text
} //end else if
Code sample: Retrieve the body of a message
Object obj=message.getContent();
if(obj instanceof Multipart){
Multipart mp=(Multipart)obj;
if(mp.getContentType().equals(ContentType.MULTIPART_ALTERNATIVE){
for(int i=0;i<mp.getCount();i++){
BodyPart bp=mp.getBodyPart(i);
if(bp instanceof MimeBodyPart){
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...