Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

javamail: how to check if a message has an attachment

665 views
Skip to first unread message

Ravi Jupudy

unread,
Jul 29, 2002, 4:45:36 PM7/29/02
to
Hi,
In my program when I display the message list in a folder, I want to
show to the user if the message has an attachment or not.

I've been doing this by using the following code:
if (msg.isMimeType("multipart/*"))
// this has attachment
else
// no attachment

Unfortunately this doesn't always work. When I have message that has
just the attachment and no message body, the mime type of the message is
not "multipart/*", how do I solve it for such messages?

thanks,
Ravi

Frank Breuer

unread,
Jul 30, 2002, 2:12:08 AM7/30/02
to
Ravi Jupudy <ravi....@oracle.com> wrote in
news:3D45A970...@oracle.com:

> When I have message that has
> just the attachment and no message body, the mime type of the
> message is not "multipart/*", how do I solve it for such messages?

Then it does not have an attachment. What you call an attachment in
this case is just the message.

What you might want to do is to flag every mail that has a mime type,
and were the mime type different from text/plain as "having an
attachment". You might include text/html in that check, too (to be
compatible with some broken and brain dead MS mailer). Or you just
check for text/*.

0 new messages