Retrieve the body of a message without an attachment
Message.getContent()
1.
Invoke
Object obj=message.getContent();
2. If the content of the message is a
if(obj instanceof Multipart){
Multipart mp=(Multipart)obj;
}
3. If the content of the message is of type
Multipart
the
object, storing each reference to a
if(mp.getContentType().equals(ContentType.MULTIPART_ALTERNATIVE){
for(int i=0;i<mp.getCount();i++){
BodyPart bp=mp.getBodyPart(i);
BodyPart
4. If a
object is of type
variable.
if(bp instanceof MimeBodyPart){
String type=bp.getcontentType();
5. Check if the content type of the
if(type.equals(ContentType.TYPE_TEXT_HTML_STRING){
6. Check if the content type of the
}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 mp=(Multipart)obj;
3. If the content of the message is of type
Multipart
object, storing each reference to a
if(mp.getContentType().equals(ContentType.MULTIPART_MIXED){
for(int i=0;i<mp.getCount();i++){
BodyPart bp = mp.getBodyPart(i);
.
Multipart
object, cast the message content as a
multipart/alternative
BodyPart
MimeBodyPart
, store the content type of the
BodyPart
object is text_html.
BodyPart
object is
TextBodyPart
.
Multipart
object.
multipart/mixed
BodyPart
, iterate through the
BodyPart
object in a
BodyPart
.
, iterate through
BodyPart
object in a
BodyPart
variable.
3: Work with a message
Multipart
object.
BodyPart
objects in
variable.
String
object in a
objects in the
17