Link to home
Start Free TrialLog in
Avatar of seenuv
seenuv

asked on

About JavaMail;

Please have a look in the snippet of this code

I am just trying to get a number of messages in a folder.


import javax.mail.*;
import java.io.*;
import java.net.*;
import java.util.*;

class first{
      public static void main(String[] args) throws MessagingException{
                  URLName urln = new URLName("164.164.61.24");
                  Properties pros = System.getProperties();
                  Session session = Session.getDefaultInstance(pros, null);
                  Store store = session.getStore();
                  store.connect();
                  Folder f = store.getDefaultFolder();
                  System.out.println("The count is " + f.getMessageCount());
      }
}

It is compiling perfectly but when it comes to runtime it is giving me this error

C:\jdk1.2\bin\java.exe   first
Working Directory - C:\javamail\testing\
Class Path - c:\jdk1.2\lib\;c:\jsdk2.1\servlet.jar;c:\jsdk2.1\server.jar;c:\javamail\javamail-1.1.2\mail.jar;.;C:\kawa321\kawaclasses.zip;c:\jdk1.2\lib\tools.jar;c:\jdk1.2\jre\lib\rt.jar
javax.mail.NoSuchProviderException: Invalid protocol: null
      at javax.mail.Session.getProvider(Session.java:208)
      at javax.mail.Session.getStore(Session.java:306)
      at javax.mail.Session.getStore(Session.java:286)
      at javax.mail.Session.getStore(Session.java:272)
      at first.main(first.java:11)
Exception in thread "main" Process Exit...

Pleaes help me to solve this error
ASKER CERTIFIED SOLUTION
Avatar of laurentj
laurentj

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial