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 7851703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:14:44+00:00 2026-06-02T19:14:44+00:00

I can receive my mails with Imap with this code sample : URLName server

  • 0

I can receive my mails with Imap with this code sample :

URLName server = new URLName("imaps://" + username + ":"+ password + "@imap.gmail.com/INBOX");
    Session session = Session.getDefaultInstance(new Properties(), null);
    Folder folder = session.getFolder(server);
if (folder == null) 
{
    System.exit(0);
}
   folder.open(Folder.READ_ONLY);
   Message[] messages = folder.getMessages();

But sometimes Imap doesn’t give any service and at those times I want to use Pop but I couldn’t use it with my code. It is different the other codes for using receive mail. But in Android only this code is working.

What should I change in this code to work with Pop?

  • 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-02T19:14:48+00:00Added an answer on June 2, 2026 at 7:14 pm

    First, there’s a nice URLName constructor that takes all the component pieces as separate parameters, so you don’t have to do string concatenation.

    Switch from IMAP to POP3 requires changing the protocol name as well as the host name. See the JavaMail FAQ for examples. The protocol name is “pop3s” and the host name is “pop.gmail.com”.

    Finally, you should use Session.getInstance instead of Session.getDefaultInstance. Compare the javadocs for the two methods to understand why.

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

Sidebar

Related Questions

how can i receive a file sent by an applet to the server by
Does anyone see anything wrong with this code: MailMessage msg = new MailMessage(); msg.From
How can I receive and send email in python? A 'mail server' of sorts.
1) How can a linux server be configured such that it can receive any
We have a client that can't receive emails from a dedicated server using PHP
Gmail can redirect email elsewhere. And, as far as I understand, my server can
I am using this with Gmail's SMTP server, and I would like to search
My android application need to communicate with the gmail server to receive emails from
I implemented IDispatchMessageInspector and in method AfterReceiveRequest I can receive name of method (action)
Im about to develop notifications for my app. In whatsapp you can receive group

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.