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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:32:16+00:00 2026-06-13T05:32:16+00:00

I am working through oracle’s tutorial on using the javamail api to access my

  • 0

I am working through oracle’s tutorial on using the javamail api to access my email. Here is my code:

 import javax.mail.*;
 import javax.mail.internet.*;
 import java.util.Scanner;
 import java.util.Properties;

 public class MailClient {
    public static void main(String[] args) {
    Properties props = new Properties();
    Session session = Session.getDefaultInstance(props, null);


    Store store = session.getStore("pop3");
    store.connect("pop.gmail.com","email@gmail.com","password");

    Folder folder = store.getFolder("INBOX");
    folder.open(Folder.READ_ONLY);
    Message message[] = folder.getMessages();
    int i = message.length;
    for (int a=0;a<i;a++) {
        System.out.println(message[i].writeTo());
    }
    Scanner pause = new Scanner(System.in);
    folder.close(false);
    store.close();
}
}

And here is the error I am receiving:

MailClient.java:20 error: method writeTo in interface Part cannot be applied to given types;
System.out.println(message[i].writeTo());
required: OutputStream
found: no arguments
reason: actual and formal argument lists differ in length
1 error

Any ideas what am I doing wrong?

Also, on Google’s page, they stated that users would need to use SSL to connect via POP3. How will I implement that in the JavaMail API? Thanks!

  • 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-13T05:32:18+00:00Added an answer on June 13, 2026 at 5:32 am

    As indicated, your error is in

    System.out.println(message[i].writeTo());
    

    There are two problems:

    1. Message.writeTo() takes an OutputStream as an argument, and you havent supplied one.

    2. writeTo() returns void, so is not a valid argument to println()

    Here is some sample code that connects to GMail via the java mail api, using POP3 and SSL

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

Sidebar

Related Questions

I've been working through the Oracle tutorial for images this one here: import java.awt.*;
I am working through the example from https://blogs.oracle.com/arungupta/entry/java_ee_6_and_nosql . Here is a link to
I'm using ADO.NET to connect to an Oracle DB through ODBC. Everything is working
My native query below is working fine oracle sqlplus. But through JPA native query,
I am working through the EditableGrid demos modifying the code to understand it and
I am working through the tutorials on writing custom spring namespace handlers found here:
I am currently working through Michael Hartl's Rails Tutorial while experimenting with some other
Hi i'm working through the Hartl's Ruby on Rails Tutorial and i'm stuck with
I'm working through the Django tutorial and receiving the following error when I run
I'm working on a project that connects to Oracle. It Brings back data through

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.