how to check for attachments
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   TEJINDER_SINGH
Posted On:   Thursday, June 22, 2006 05:29 AM

if i want to check whether any mail contains any attachments i have used the following code .but even for mails that are only text it says that attachment is there. Even for plain text mail it says that there are two parts.how is it so. kindly help Multipart mp = ((Multipart)message).getContent(); for (int i=0, n=mp.getCount(); i { Part part = mp.getBodyPart(i); String disposition = part.getDisposition(); if ((disposition != null) && (disposition.equals(Part.ATTACHMENT) || disposition.equals(Part.INLINE))) { out.println("there is attachment"); } } the output is always there is attachmen   More>>

if i want to check whether any mail contains any attachments i have used the following code .but even for mails that are only text it says that attachment is there. Even for plain text mail it says that there are two parts.how is it so.
kindly help


Multipart mp = ((Multipart)message).getContent();

for (int i=0, n=mp.getCount(); i

{

Part part = mp.getBodyPart(i);

String disposition = part.getDisposition();

if ((disposition != null) && (disposition.equals(Part.ATTACHMENT) ||
disposition.equals(Part.INLINE)))

{

out.println("there is attachment");

}

}

the output is always there is attachment for every mail
thanks
tejinder

   <<Less
About | Sitemap | Contact