How to get unread message count

I m working in mail application where i need to get the unread message count.Can anyone help me out in solving this issue ,is there any specific method available in javamail to get this count.
Thanx in Advance

Is there some reason you're unable to read the
javadocs? Did you find them too confusing?
What's wrong with the method Folder.getUnreadMessageCount?
Oh, and if you're using POP3 instead of IMAP,
read the FAQ and the com.sun.mail.pop3 package
javadocs.

Similar Messages

  • How to get unread messages

    Hi,
    I have the following code
    Folder folder=store.getFolder("INBOX");
    Message[] message=folder.getMessages();
    The getMessages method is supposed to return all the messages from inbox,but I only get new messages.I can read the new message but,how can I mark the message that I already read.When I run my program,it always reads all the new messages.What I mean is,in outlook,all the new messages are highlighted,my program can always read those.How can I make the message without highlight.I am using POP3 for incoming mail.
    Thanks
    Ravi.

    hello friends if you are reading mail from gmail use following properties
    props=System.getProperties();
                 props.setProperty( "mail.imap.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
                props.setProperty( "mail.imap.socketFactory.fallback", "false");
                props.setProperty("mail.imap.port", "993");
                props.setProperty("mail.imap.socketFactory.port", "993");// for gmail
                   props.put("mail.imap.host", "imap.gmail.com");
    auth=new SMTPAuthenticator("[email protected]","password");
                      session=Session.getDefaultInstance(props,auth);
              store=session.getStore("imap");
    by checking flag values you can differentiate mail is read or unread
         Flags flags=msg[k].getFlags();
                            Flags.Flag[] sf=flags.getSystemFlags();
                   for (int i = 0; i < sf.length; i++) {
                      if (sf[i] == Flags.Flag.DELETED)
                          System.out.println("DELETED message");
                           else if (sf[i] == Flags.Flag.SEEN)
                          System.out.println("SEEN message");
                          else if (sf[i] == Flags.Flag.ANSWERED )
                          System.out.println("ANSWERED  message");
                          else if (sf[i] == Flags.Flag.DRAFT )
                          System.out.println("DRAFT  message");
                          else if (sf[i] == Flags.Flag.FLAGGED)
                          System.out.println("FLAGGED message");
                          else if (sf[i] == Flags.Flag.RECENT)
                          System.out.println("RECENT message");
                          else if (sf[i] == Flags.Flag.USER)
                          System.out.println("USER message");
    or check
    msg[k].isSet(Flags.Flag.SEEN)
    is true or false

  • Inbox and Drafts show unread message count of all folders within. Can I get the local folders to do this too?

    I'm filtering mail into folders in the local folder tree. There may be two or three levels, e.g., Local Folders -> Lists -> OS -> MacOSX. Mail that is unread in the MacOSX folder is counted and displayed when the MacOSX folder is visible. However, keeping the entire tree on display is a nuisance and it is long, so I don't see things ate the bottom. I have to scroll to reveal the rest of the items in the folder tree. For these reasons I'd prefer to have the folder tree in its minimal state.
    Is it possible to have the the top level folders display an unread message count for all the enclosed folders?

    when I collapse the folder tree of local folders, it shows the unread count for sub folders.

  • Some solutions for screwy unread message counts

    I've recently found solutions to two Mail.app (version 2.0.5) problems
    I'd been having, and figured I'd share them. My apologies if these
    duplicate things already said here by othersq; a quick Google didn't
    turn these up for me.
    Problem 1: Mail spontaneously becomes unread after reading it. In my
    case, at least, this was directly correlated with installing the
    GPGMail plugin, and went away when I removed the plugin. According to
    http://www.sente.ch/Lists/gpgmail-users/Message/847.html you can solve
    this problem by tweaking GPGMail's configuration; I haven't tried this
    myself yet, but will soon.
    Problem 2: Unread message counts are sometimes unreasonably high in
    IMAP folders. In my case, I would receive one piece of email, and my
    "Unread Messages" Smart Folder would report that I had 8 unread pieces
    of email. When I would click on the folder, it would show me just the
    one piece of mail, and the count next to the smart folder would go
    away.
    I should note here that I had configured Mail.app NOT to move deleted
    messages to a Trash folder.
    It turns out that when I selected View->View Deleted Messages, I could
    see another 7 unread --- but deleted --- messages. (All were spam that
    I had manually "moved" to another folder, which, when Mail.app is
    configured not to move deleted messages to a Trash folder, leaves
    behind a deleted copy in the original folder. Oddly, when Mail.app
    is configured to move deleted messages to a Trash folder, moving a
    message leaves no deleted body behind in either the source folder, or
    in the Trash folder. This seems inconsistent to me, but that's
    another matter entirely.)
    Anyhow, the 8-or-0 count seems to be due to an inconsistency in how
    Mail.app counts deleted-yet-unread messages: when a new message comes
    in, it includes deleted, but unread, messages in its unread message
    count; but after you've read that new message, it no longer includes
    deleted, but unread, messages when it updates the count. So the count
    goes from 8 to 0... until the next time you get mail.
    Incidentally, another side-effect of this bug is that partial copies
    of an email message saved in your Drafts folder, and then deleted when
    you sent the mail, cause the Drafts folder to show a non-zero count
    whenever you receive a new piece of mail --- even though clicking on
    it will show it to be empty (until you start viewing deleted
    messages.)
    The workaround for all of this seems to be to configure Mail.app to
    always move deleted messages to the Trash folder I think this is
    probably the default configuration; I had changed it for reasons which
    I no longer remember.
    I am posting this information to the apple.com mail suport forum and
    to the macintouch mail.app forum, and I am reporting the bug to Apple
    via the ADC bugtracker.
      Mac OS X (10.4.3)  

    Sorry I am marking this solved, but it never was.
    The best thing that could be done is to rely on Time Machine, or forward all of your incoming email to another address.
    Apparently, there is no way to do what I asked. But there should be. So Apple, please fix this.
    Again, sorry I am marking it as solved.

  • Unread message count not updating in Mail.app

    I am running a MBP 15" with 10.4.10 and Mail.app (version 2.1.1 build 752.3) and as you can see in this screengrab here:
    the unread message count is not correctly updating.
    This may actually be something for the Mail dev' team to handle, unless some one else out there in the groups has some inside knowledge about this issue.
    For that matter, I do not know how to forward this to the Mail dev' team inside Apple, so if any one else does, please do.
    Cheers.
    Jason
    MBP 15; 2.16 ghz; 2gb RAM; 100gb;   Mac OS X (10.4.10)   Palm Treo 680 + Cisco 1242 WAP + xo.net + Hyatt Embarcadero room service

    Jason,
    What screengrab?
    What type of account do you have -- POP, IMAP or .mac? How many accounts do you have? Do you access your account from more than one computer?
    Unread message count where -- on the Mail Icon in the Dock or in individual mailboxes? In the Dock, the Unread message count will NOT reflect any messages moved to custom mailboxes by Rules, but only those in the Inboxes.
    Ernie

  • To get unread messages in any folder "exactly once"

    What am trying to do?
    a. Poll the mail server(might be MS or gmail or yahoo..) (say now).
    b. Get unread messages from a mailbox folder via IMAP. (via +'SEEN'+ flag)
    c. Process the unread messages i.e. in my case i will send SMS to users according to filters specified.
    d. Sleep and Poll the mail server after 10 min(say)
    e. Now the question is how to do i get the next set of unread messages i.e. the unread messages other than those that i got in step (b)
    Rules-
    a. Note that i can't set the message as '+READ+' or '+SEEN+' as mine is not the standard client.
    b. I think i can get hold of the largest message UID in the first poll and save it and in the next poll try to retrieve only the unread
    messages with UID greater than that i saved. +But is there any good and easy approach to do the above+?
    c. Also to be clear, in the interim period between two polls, if the user really reads a mail via his/her client, then in the next poll i am not interested in those read mails. So the question arises only if the user doesn't check any mail where my application really comes into picture
    Please assist. Ping me if am unclear.

    Thanks. It's working for 'IMAP'. I need it for IMAP only.

  • Unread messages count is wont for Smart Mailbox

    Has anyone else noticed that a smart mailbox has a non-zero unread message count but as soon as it is clicked on the count is reset to zero? Zero is correct because all of the messages have been read. I've tried rebuilding the inbox but it hasn't helped. I also recreated the smart mailbox but that didn't help either. Sounds like a bug to me but I wonder if others have experienced it. I am using Mail Tags so that is a possible complication.

    Same problem here with Yahoo mail.  Sometimes it works, sometimes it doesn't.  I have looked at Yahoo mail from all folders in my phone (running 7.0.3 now), as well as in a browser, looked at Inbox (empty), all Trash, Sent, etc. folders and they're completely empty on Yahoo servers.
    I thought that 7.0.3 had initially cleared up this issue but it has reappeared, and I don't know how to fix it.

  • Yahoo! Mail in Mail App on iPad 2 iOS 7.0.3 Shows Unread Message Count

    Yahoo! Mail in Mail App on iPad 2 iOS 7.0.3 shows unread message count when the Inbox is empty.  This has been an ongoing issue since iOS 7 rolled out.  I was hoping with this latest update that this problem would be fixed.  Just wanted to report it.  If someone knows where bugs get reported, I'd appreciate the link.
    None of my other mail programs have this problem.
    I perform a reset (holding down the Home button and the Power button) and sometimes this clears it out and sometimes not.  Plus, I don't want to reset my iPad on a constant basis just to clear my mail count.
    Any insight or additional information is appreciated.

    I think it's an issue with yahoo. I have the same basic set up as you and will open my mail, see that I have 4 unread for example, read them, exit mail and have the red bubble still reading 4 unread mail. Usually it catches up and corrects in a little bit.
    Probably jus a glitch between yahoo and the mail app and not much you can do as a user but wait it out or get used to it...or I understand that there's a yahoo app if it really bugs you.

  • I have Lion, and I can't see my unread messages count in the dock, even after the preferences set up. I find the Lion Mail too complicated. Leopard was much easier and more simple to use. I only have one account& don't need all the rest. any suggestions

    I have Lion, and I can't see my unread messages count in the dock, even after the preferences set up.
    I find the Lion Mail too complicated. Leopard was much easier and more simple to use. I only have one account& don't need all the rest.
    any suggestions?

    weird.
    It's so frustrating, I got my Mac Book 5 days ago and I'm already having a discussion in the forum.
    Thank you so much for your prompt replies.
    It's past midnight here so I'd better get some rest...
    Good night captfred!

  • Gmail tab never updates unread message count

    I'm using OS X 10.9.1 and Safari 7.0.1.
    The tab that I have for Gmail never updates the unread message count.  It constantly says 27 and has done that ever since I got my MacBook which has newer versions of everything over my old MacBook which was running 10.7.  I've tried deleting cookies and clearing the cache and such but the tab still says 27 unread emails even though, as of this writing, I have 29 unread emails.
    Is there any way to fix this?

    Since I last brought this up 4 months ago, Safari has been updated to 7.0.3 and OS X is now at 10.9.2 and I'm still having the same issue.  The GMail tab always says 27.  Though now I can refresh the page and get it to update the count and it will continue to update correctly after that.  But it always starts at 27 and I have to force a refresh of the page to get it to update.
    Scratch some of that.  I went into the bookmarks and deleted the "(27)" from the name of the bookmark.  Now when the tab loads, it simply says "Inbox - " followed by my email address.  And only after I reload the page does it have an unread email count which is correct. 
    Does anyone have any suggestions?

  • How to get the row Count of a ResultSet

    How to get the row Count of a ResultSet

    Hi
    I'v tried rennie1's way ,but I only get zero,my code is:
    rs.executeQuery("select count(*) from t_test");
    if (rs.next()) int rowCount=rs.getInt(1);
    I also tried barni's way ,but the method rs.last() and rs.beforeFirst() throw a same Exception
    I tried another way,the code is:
    while rs.next(){
    // Do nothing ,just move the cursour to the last row
    int rowCount=rs.getRow()
    However,the rowCount still equal zero
    Any help would be greatly apprecite!
    note:
    I get connection by DataSource's JNDI name from client, the Server is Weblogic Server 6, the DBMS is Oracle.

  • How to get  visible row  count  in JTable ?

    I have one table which is added to one scroll pane. For example my table have total 1000 rows, but at a time only 20 rows should be visible to the scroll pane. And I want to scroll the rows and show only 20 at a time.When user scrolls JTable then next time he can view only 1 to 21, then 2 to 22, and so on. I want to know how to get that number which represents the visible row( in this case it is 20).So kindly help me how to get visible row count. Any help regarding this will be appriciated.
    Thanks and Regards,
    Sheetal

    how to get visible row count.First you need to get the viewport used by the scrollpane. Then you can use methods like getViewPosition() and getViewSize() to get information about the current postition of and size of the viewport.
    Then you can use the table method getRowAtPoint(). to determine the first and last visible row which can then be used to calculate the visible row count.
    When user scrolls JTable then next time he can view only 1 to 21, then 2 to 22, and so onThis is the default behaviour when a "block" scroll is done.
    However when you click on the arrow button on the scrollbar it will only scroll a single row. You could override the getScrollableUnitIncrement() method to return the value from the getScrollableBlockIncrement() method.
    However the user can still drag the scrollbar manually which would cause a problem. So you would also need to remove the MouseMotionListeners from the scrollbar to prevent this.

  • How to get file line count.

    Hey guys,
    How to get file line count very fast? I am using BufferedReader to readLine() and count. But when dealing with big file, say several GB size, this process will be very time consuming.
    Is there any other methods?
    Thanks in advace!

    What I'd do is you create an infofetcher, register a listener, implement gotMore() and have that scan for '\n'
    Some might suggest getting rid of the listener/sender pattern or use multiple threads to make ii faster. This might help a little, but only if your I/O is super-duper speedy.
    you are welcome to use and modify this code, but please don't change the package or take credit for it as your own work.
    InfoFetcher.java
    ============
    package tjacobs.io;
    import java.io.IOException;
    import java.io.InputStream;
    import java.util.ArrayList;
    import java.util.Iterator;
    * InfoFetcher is a generic way to read data from an input stream (file, socket, etc)
    * InfoFetcher can be set up with a thread so that it reads from an input stream
    * and report to registered listeners as it gets
    * more information. This vastly simplifies the process of always re-writing
    * the same code for reading from an input stream.
    * <p>
    * I use this all over
         public class InfoFetcher implements Runnable {
              public byte[] buf;
              public InputStream in;
              public int waitTime;
              private ArrayList mListeners;
              public int got = 0;
              protected boolean mClearBufferFlag = false;
              public InfoFetcher(InputStream in, byte[] buf, int waitTime) {
                   this.buf = buf;
                   this.in = in;
                   this.waitTime = waitTime;
              public void addInputStreamListener(InputStreamListener fll) {
                   if (mListeners == null) {
                        mListeners = new ArrayList(2);
                   if (!mListeners.contains(fll)) {
                        mListeners.add(fll);
              public void removeInputStreamListener(InputStreamListener fll) {
                   if (mListeners == null) {
                        return;
                   mListeners.remove(fll);
              public byte[] readCompletely() {
                   run();
                   return buf;
              public int got() {
                   return got;
              public void run() {
                   if (waitTime > 0) {
                        TimeOut to = new TimeOut(waitTime);
                        Thread t = new Thread(to);
                        t.start();
                   int b;
                   try {
                        while ((b = in.read()) != -1) {
                             if (got + 1 > buf.length) {
                                  buf = IOUtils.expandBuf(buf);
                             int start = got;
                             buf[got++] = (byte) b;
                             int available = in.available();
                             //System.out.println("got = " + got + " available = " + available + " buf.length = " + buf.length);
                             if (got + available > buf.length) {
                                  buf = IOUtils.expandBuf(buf, Math.max(got + available, buf.length * 2));
                             got += in.read(buf, got, available);
                             signalListeners(false, start);
                             if (mClearBufferFlag) {
                                  mClearBufferFlag = false;
                                  got = 0;
                   } catch (IOException iox) {
                        throw new PartialReadException(got, buf.length);
                   } finally {
                        buf = IOUtils.trimBuf(buf, got);
                        signalListeners(true);
              private void setClearBufferFlag(boolean status) {
                   mClearBufferFlag = status;
              public void clearBuffer() {
                   setClearBufferFlag(true);
              private void signalListeners(boolean over) {
                   signalListeners (over, 0);
              private void signalListeners(boolean over, int start) {
                   if (mListeners != null) {
                        Iterator i = mListeners.iterator();
                        InputStreamEvent ev = new InputStreamEvent(got, buf, start);
                        //System.out.println("got: " + got + " buf = " + new String(buf, 0, 20));
                        while (i.hasNext()) {
                             InputStreamListener fll = (InputStreamListener) i.next();
                             if (over) {
                                  fll.gotAll(ev);
                             } else {
                                  fll.gotMore(ev);
    InputStreamListener.java
    ====================
    package tjacobs.io;
         public interface InputStreamListener {
               * the new data retrieved is in the byte array from <i>start</i> to <i>totalBytesRetrieved</i> in the buffer
              public void gotMore(InputStreamEvent ev);
               * reading has finished. The entire contents read from the stream in
               * in the buffer
              public void gotAll(InputStreamEvent ev);
    InputStreamEvent
    ===============
    package tjacobs.io;
    * The InputStreamEvent fired from the InfoFetcher
    * the new data retrieved is from <i>start</i> to <i>totalBytesRetrieved</i> in the buffer
    public class InputStreamEvent {
         public int totalBytesRetrieved;
         public int start;
         public byte buffer[];
         public InputStreamEvent (int bytes, byte buf[]) {
              this(bytes, buf, 0);
         public InputStreamEvent (int bytes, byte buf[], int start) {
              totalBytesRetrieved = bytes;
              buffer = buf;
              this.start = start;
         public int getBytesRetrieved() {
              return totalBytesRetrieved;
         public int getStart() {
              return start;
         public byte[] getBytes() {
              return buffer;
    ParialReadException
    =================
    package tjacobs.io;
    public class PartialReadException extends RuntimeException {
         public PartialReadException(int got, int total) {
              super("Got " + got + " of " + total + " bytes");
    }

  • How to get automatic message output

    Hi,
    How to get automatic message output while creating po cause i have done all setting in the config but still it does not work what else i have to do.
    And 1 more thing how we can maintain condition record for Printoutput & External send for one output type.
    Regards,
    Anant

    Hi,
    Please follow the below steops for the Output of Purchase Order
    1. Condition Table
    SPRO > Material Management> Purchasing -> Message -> Output Control->Condition Tables->Define Condition Table for Purchase Order
    Select:
    Purchasing Doc. Type, Purch. Organization, Vendor
    2. Access Sequences
    SPRO ->     -> Purchasing -> Message -> Output Control->Access Sequences->Define Condition Table for Purchase Order
    3. Message Type
    SPRO -> Material Management-> Purchasing -> Message -> Output Control->Message Types->Define Message Type for Purchase Order
    *4. Message Determination Schemas*
    4.1. Message Determination Schemas
    SPRO -> Material Management-> Purchasing -> Message -> Output Control->Message Schema->Define Message Schema for Purchase Order-> Maintain Message Determination Schema
    4.2. Assign Schema to Purchase Order
    SPRO -> Material Management-> Purchasing -> Message -> Output Control->Message Schema->Define Message Schema for Purchase Order-> Assign Schema to Purchase Order
    5. Partner Roles per Message Type
    SPRO -> Material Management-> Purchasing -> Message -> Output Control-> Partner Roles per Message Type ->Define Partner Role for Purchase Order
    6. Condition Record
    Navigation Path: SAP Menu-> Logistics -> Material Management -> Purchasing-> Master data-Messages- MN04
    Here you can maintain the condition record.
    All above steps u can do from transacton NACE also
    now when u create po in the messages u will get the out put method as u have maintained in the above steps.
    Regards,
    Manish

  • Before page refresh how to get alert message

    Hello ..
    If user refreshes webpage then from flex side how to get alert message.
    Thanks in advance.

    If you don't want it to say "Microsoft Internet Explorer," you can use a different browser. :-)
    But, seriously...
    If you really want to customize the appearance of a dialog, you can make one with DHTML that looks like anything you want. You can make it look like a system dialog if you want, but you don't have to. (In fact, if you make it look like a Windows dialog, it will stick out like a sore thumb if someone is using another OS.)
    I had to create some of these for an online testing application I wrote, because they wanted the tests to be timed, and I discovered that, in Internet Explorer, you could stop the clock just by opening certain dialogs, so I had to suppress "right-clicking," remove the menu bars, and use custom dialogs to communicate with the user. Since then I've re-used these dialogs in a number of other projects. They're pretty handy.

Maybe you are looking for