Methods Summary |
---|
public javax.mail.Folder | getFolder()Returns the javax.mail.Folder object.
return folder;
|
public java.lang.String | getHostname()hostname getter method.
return hostname;
|
public int | getMessageCount()Returns the number of messages in the folder.
return folder.getMessageCount();
|
public java.lang.String | getPassword()password getter method.
return password;
|
public javax.mail.Session | getSession()session getter method.
return session;
|
public javax.mail.Store | getStore()store getter method.
return store;
|
public javax.mail.URLName | getUrl()url getter method.
return url;
|
public java.lang.String | getUsername()username getter method.
return username;
|
public boolean | isLoggedIn()Method for checking if the user is logged in.
return store.isConnected();
|
public void | login()Method used to login to the mail host.
url = new URLName(protocol, getHostname(), -1, mbox,
getUsername(), getPassword());
/*
* First, try to get the session from JNDI,
* as would be done under J2EE.
*/
try {
InitialContext ic = new InitialContext();
Context ctx = (Context)ic.lookup("java:comp/env");
session = (Session)ctx.lookup("MySession");
} catch (Exception ex) {
// ignore it
}
// if JNDI fails, try the old way that should work everywhere
if (session == null) {
Properties props = null;
try {
props = System.getProperties();
} catch (SecurityException sex) {
props = new Properties();
}
session = Session.getInstance(props, null);
}
store = session.getStore(url);
store.connect();
folder = store.getFolder(url);
folder.open(Folder.READ_WRITE);
|
public void | login(java.lang.String hostname, java.lang.String username, java.lang.String password)Method used to login to the mail host.
this.hostname = hostname;
this.username = username;
this.password = password;
login();
|
public void | logout()Method used to logout from the mail host.
folder.close(false);
store.close();
store = null;
session = null;
|
public void | setHostname(java.lang.String hostname)hostname setter method.
this.hostname = hostname;
|
public void | setPassword(java.lang.String password)password setter method.
this.password = password;
|
public void | setSession(javax.mail.Session session)session setter method.
this.session = session;
|
public void | setStore(javax.mail.Store store)store setter method.
this.store = store;
|
public void | setUsername(java.lang.String username)username setter method.
this.username = username;
|