Can any help me out to code the java program that filters only the mails which contains attachments?
Asked
Active
Viewed 829 times
0
-
What you have tried till now? – Abhijeet Dhumal Jun 22 '15 at 07:07
-
take a look at http://stackoverflow.com/questions/348630/how-can-i-download-all-emails-with-attachments-from-gmail – Mohit Kanwar Jun 22 '15 at 07:12
-
Hi,thanks for response,actually I want to know SearchTerm that filters only the mails with attachment.Is there any such kind of class like FromTerm,BodyTerm,etc..!! – prasad Jun 22 '15 at 08:16
1 Answers
0
In the general case, it's not simple to tell whether a message has attachments. You'll find more information in the JavaMail FAQ. You can search for messages with a Content-Type header containing "multipart", but then you'll need to look at each of those messages more closely to determine whether any of them really does have attachments. You have to decide whether you only want to handle simple cases or more complex cases as well.

Bill Shannon
- 29,579
- 6
- 38
- 40
-
Thank you so much @Bill Shannon for your prompt response,actually even for some text mails also we are getting Content-Type with 'multipart', that's why I got the question i.e can we find whether the attachment is there or not ,with out going through all bodyparts? .Any ways thanks again. – prasad Jun 25 '15 at 09:06
-
MIME allows a multipart message to have only a single text body part, and some poor quality mailers will just always create multipart messages, that's just one of the reasons why it's difficult to tell if a message has attachments or not. – Bill Shannon Jun 25 '15 at 16:22