Exception in thread "main" javax.mail.NoSuchProviderException: invalid prov

HI,

I am trying to read mails from my inbox i amgetting the ErrorC:\javamail>java

Readmail

Exception in thread"main" javax.mail.NoSuchProviderException: No providerfor IMAP

at javax.mail.Session.getProvider(Session.java:455)

at javax.mail.Session.getStore(Session.java:530)

at javax.mail.Session.getStore(Session.java:510)

at Readmail.main(Readmail.java:24)

My Code is{

String host ="hostname";

String username ="user";

String password ="password";

// Create empty properties

Properties props =new Properties();

// Get session

Session session = Session.getDefaultInstance(props,null);

// Get the store

Store store = session.getStore("IMAP");

store.connect(host, username, password);

// Get folder

Folder folder = store.getFolder("Inbox");

folder.open(Folder.READ_ONLY);

// Get directory

Message message[] = folder.getMessages();

for (int i=0, n=message.length; i<n; i++)

{

System.out.println(i +": " + message[i].getFrom()[0]

+"\t" + message[i].getSubject());

}

// Close connection

folder.close(false);

store.close();

I have also tried POP3 and MIME and SMTP

Can anyone help me Thanks>

[1975 byte] By [Ashitosha] at [2007-11-26 16:12:48]
# 1
The protocol names are all lowercase.
bshannona at 2007-7-8 22:35:29 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2

hi bshannon,

I am getting the same error for others but for pop3 the error is as below

Exception in thread "main" javax.mail.MessagingException: Connect failed;

nested exception is:

java.net.ConnectException: Connection refused: connect

at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:148)

at javax.mail.Service.connect(Service.java:275)

at javax.mail.Service.connect(Service.java:156)

at Readmail.main(Readmail.java:25)

Caused by: java.net.ConnectException: Connection refused: connect

at java.net.PlainSocketImpl.socketConnect(Native Method)

at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)

at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)

at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)

at java.net.Socket.connect(Socket.java:452)

at java.net.Socket.connect(Socket.java:402)

at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:232)

at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)

at com.sun.mail.pop3.Protocol.<init>(Protocol.java:81)

at com.sun.mail.pop3.POP3Store.getPort(POP3Store.java:201)

at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:144)

... 3 more

Ashitosha at 2007-7-8 22:35:29 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3
See the JavaMail FAQ for tips on debugging connection problems.
bshannona at 2007-7-8 22:35:29 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 4
hi bshannon ,I read the FAQ and tried pop3s but still getting the same error.See i am able to send mails but not able to read it from the inbox also i am not able to store them in senditem of outlook.
Ashitosha at 2007-7-8 22:35:29 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 5
Which of the connection debugging steps did you try? Which onesworked and which ones failed?
bshannona at 2007-7-8 22:35:29 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 6

hi bshannon ,

See i have read the SSLNOTES.txt and came to know of Pop3s and tried to use it.But still getting the above error And also during sending the mail we can't see the mail in the send item.How can we save a copy in send item as it generally happens when we send a mail through outlook.

The second question is more important than the first one

Thanks in Advance

Ashitosha at 2007-7-8 22:35:29 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 7

I can't help you with your connection problem because you won't tell me

what happened when you tried the various debugging steps explained in

the FAQ.

As for saving a copy of your outgoing mail, see the msgsend.java demo

for an example. Note that you can't do it using POP3, which supports

only a single mailbox - INBOX.

bshannona at 2007-7-8 22:35:29 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 8
Thanks bshannon , I will come back with my first question afterwards.First i will read the full FAQ for debugging connection.
Ashitosha at 2007-7-8 22:35:29 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...