How can I show unread mail count of Gmail,Yahoo,AOL in my web application?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   ankit_patel
Posted On:   Thursday, August 14, 2008 11:21 AM



I want to show unread mail count for Gmail,Yahoo,AOL,MSN (e.g. Gmail (5) ) on my web application. Also when user click on unread mail count it should open new window for respective mail Inbox say gmail inbox that shows unread mail of user.
I have exercised on jgmail source code & it has used HttpClient API to login into gmail and access services of gmail but I am not able to execute it successfully.
what are the options for above questions?




Thanks In Advance
Ankit Patel

Re: How can I show unread mail count of Gmail,Yahoo,AOL in my web application?

Posted By:   Anonymous  
Posted On:   Friday, September 12, 2008 03:43 AM

public void readMail() throws IOException, MessagingException
{
Session session = null;

String username="";
String password="";


try
{
String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory";

//property
Properties pop3Props = new Properties();

pop3Props.setProperty("mail.pop3.socketFactory.class", SSL_FACTORY);
pop3Props.setProperty("mail.pop3.socketFactory.fallback", "false");
pop3Props.setProperty("mail.pop3.port", "995 ");
pop3Props.setProperty("mail.pop3.socketFactory.port", "995");


URLName url = new URLName("pop3", "pop.gmail.com", 995, "",
username, password);


session = Session.getInstance(pop3Props, null);
Store store = new POP3SSLStore(session, url);
store.connect();

/* Store store = session.getStore(url);
store.connect(mailhost, username, password);*/

//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 System.out.println(i + ": " + message[i].getFrom()[0]
+ " " + message[i].getSubject());
}

System.out.println("End");
// Close connection
folder.close(false);
store.close();


}
catch (Exception e)
{
e.printStackTrace();
}



}
About | Sitemap | Contact