Problem to access POP3 of MS Exchange Server using Java Mail
843834Jun 17 2009 — edited Dec 21 2009
{color:#0000ff}Hi,
I have a requirement to read emails from my office mailbox using POP3 protocol which is in Microsoft Exchange Server.
My code is given below.{color}
{color:#0000ff}*package emailadaptor;*
import java.util.Properties;
import javax.mail.Session;
import javax.mail.Store;
*public class Test {*
*public static void main(String[] args) {*
* // POP3 server name of Exchange Server*
* String host = "popServer.domain.com";*{color}
{color:#0000ff}*
*
* // User name*
* String user = "domainName\\userName";*
* String password = "password";
*
* // Get a session. Use a blank Properties object.*
* Session session = Session.getDefaultInstance(new Properties());
*
* try{*
* // Get a Store object*
* Store store = session.getStore("pop3");*
* store.connect(host, user, password);*
* }catch(Exception e){*
* e.printStackTrace();*
* }*
* }*
*}*
*{color:#0000ff}I can ping popServer.domain.com from my machine where I am testing the code.*
For username I have tried with domainName\\userName and username pattern both but unsuccessful. For example if my username if user1 and my domain name is domain1 than the two patterns I have tried are ‘domain1\\user1’ and ‘user1’.
For both these cases I am getting same error, and below is my error stack Trace.
*{color}*
*{color:#ff0000}javax.mail.AuthenticationFailedException: The requested mailbox is not available on this server.*
at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:158)
at javax.mail.Service.connect(Service.java:291)
at javax.mail.Service.connect(Service.java:172)
at emailadaptor.Test.main(Test.java:19)
*{color}*
*{color:#0000ff}Please give me some idea and steps what is wrong with this code and if any other information is needed then also let me know that.*
Please help.
Regards,
*Gourab{color}
*{color}