Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8156683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:02:02+00:00 2026-06-06T17:02:02+00:00

I am trying to write a simple java program which returns me all the

  • 0

I am trying to write a simple java program which returns me all the unread email from my hotmail account using javamail api. This is the code I am using :

        String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory";
    Properties props = new Properties();
    props.setProperty("mail.pop3.ssl.enable", "true");
    props.setProperty("mail.pop3s.socketFactory.class", SSL_FACTORY); 
    props.setProperty("mail.pop3s.socketFactory.fallback", "false"); 
    props.setProperty("mail.pop3s.port", "995"); 
    props.setProperty("mail.pop3s.socketFactory.port", "995");
    Session session = Session.getInstance(props,
        new javax.mail.Authenticator() {
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(username, password);
            }
        });
        Store store = session.getStore("pop3");
        store.connect("pop3.live.com", username, password);
        System.out.println(store);

        Folder inbox = store.getFolder("Inbox");
        inbox.open(Folder.READ_ONLY);
        FlagTerm ft = new FlagTerm(new Flags(Flags.Flag.SEEN), false);
        Message messages[] = inbox.search(ft);

What is my mistake in this code? Because I am getting all the mails instead of just the unread ones.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T17:02:05+00:00Added an answer on June 6, 2026 at 5:02 pm

    Quoting from Sun’s documentation about their bundled POP3 provider (which I’m assuming you are using) – the documentation is located in /docs/sundocs

    POP3 supports no permanent flags (see Folder.getPermanentFlags()). In
    particular, the Flags.Flag.RECENT flag will never be set for POP3
    messages. It’s up to the application to determine which messages in a
    POP3 mailbox are “new”. There are several strategies to accomplish
    this, depending on the needs of the application and the environment: A
    simple approach would be to keep track of the newest message seen by
    the application. An alternative would be to keep track of the UIDs
    (see below) of all messages that have been seen. Another approach is
    to download all messages into a local mailbox, so that all messages in
    the POP3 mailbox are, by definition, new. All approaches will require
    some permanent storage associated with the client.

    I think that pretty much answers your question

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to java and trying to write a simple program using JDBC. It
I'm new to java and am trying to write a simple program that basicly
I'm trying to write a simple C program on Ubuntu using Eclipse CDT (yes,
i am trying to run a very simple java program. i want to write
I'm trying to write a simple java applet program, but it seems that I'm
I'm trying to write a simple java program in Eclipse that prints these four
I just switched from C++ to Java. I'm trying to write a program that
Just getting back into using C++ and trying to convert a simple Java program
I am trying to write a simple Java function that will take a list
I'm trying to write a simple code in Java to connect to a memcache

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.