aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes Retrieving mails using Java Mail API Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Retrieving mails using Java Mail API" Watch "Retrieving mails using Java Mail API" New topic
Author

Retrieving mails using Java Mail API

Santhana Lakshmi.S
Ranch Hand

Joined: Aug 16, 2005
Posts: 82
hi,
In my project,i am retrieving mails from a particular email id.
I am able to retrieve the latest mails and save it in a folder in my system.
The problem is whenever i run the program eventhough the most recently received mail in inbox is retrieved and saved,again it is retrieving the same one and saving it in the same folder(not repeating).

I tried to check the newmessages in the inbox using the folder.hasNewMessage() method in java mail api,but the method is returning false only regardless new mail is there in inbox or not.
I want to read the unread messages only.Dont want to retrieve the already read mails.
I got the mail retrieving code from the below site.(sorry not posting the code because it is so long and having 4 classes)
http://www.builderau.com.au/program/java/soa/Getting_the_mail_in_receiving_in_JavaMail/0,39024620,39228060,00.htm

Can anyone tell me how to read unread mails in the inbox?


Thanks a lot
jack wenttohill
Greenhorn

Joined: Apr 26, 2009
Posts: 9
Message[] unreadMessages = folder.search(new FlagTerm(new Flags(Flags.Flag.SEEN), false));
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2712
    
    5

"jack wenttohill " please check your private messages for an important administrative matter. You can check them by clicking the My Private Messages link above.


SCJP, SCWCD.
|Asking Good Questions|
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
Are you using POP or IMAP? If it's POP, then this probably won't work because it relies on Flags; see my response in this topic


Ping & DNS - updated with new look and Ping home screen widget
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Retrieving mails using Java Mail API
 
Similar Threads
retrieving only new messages using POP3-Possible????
help in retrieving images from email
Java mail POP mark as read and unread
JavaMail API for Unread yahoo messages not working.
Changing JVM's Memory Allocation On The Fly