Java Mail
843830Jun 23 2002 — edited Jun 25 2002Hello,
I encountered with problem while connectingto INBOX using java mail. I could not find the solution for this.
Any solutions to this problem please.
Thnaks
Sudhakar
Error Message
C:\mail>java NewMail
Exception in thread "main" javax.mail.NoSuchProviderException: No provider for pop3
at javax.mail.Session.getProvider(Session.java:249)
at javax.mail.Session.getStore(Session.java:323)
at javax.mail.Session.getStore(Session.java:303)
at NewMail.main(NewMail.java:17)
Source code is
import javax.mail.*;
import javax.mail.internet.*;
public class NewMail {
public static void main (String args[])
throws Exception {
//,"smtp.freeserve.net"
String host = "pop.freeserve.net";
String username = "xxx@konda.freeserve.co.uk";
String password = "xxx";
// Get session
Session session = Session.getInstance(
System.getProperties(), null);
// Get the store
Store store = session.getStore("pop3");
store.connect(host, username, password);
// Get folder
Folder folder = store.getFolder("INBOX");
folder.open(Folder.READ_ONLY);
// Get Count
int count = folder.getMessageCount();
System.out.println("Messages waiting: "
+ count);
count = folder.getUnreadMessageCount();
System.out.println("Unread messages waiting: "
+ count);
// Close connection
folder.close(false);
store.close();
}
}