Javamail to receive emails; whats wrong?

放肆的年华 提交于 2020-01-17 04:47:26

问题


I am trying to create a very simple (text based for now) email app for receiving emails. So far i have used this code :

http://www.javaer.org/j2ee/3-javamail/8-javamail-connecting-gmail-using-pop3-with-ssl

The problem is that i when i run this code i am able to get the new emails, only for once. For example if i have a new message in inbox the first time i will this code it will show it but then it wont. Also it seems that i cant see the body contents of the emails which is strange. I was told that it should be better to use imap protocol but i am not entirely sure how.


回答1:


Specified example really starts once and scans folder and exits (and see answer on POP that removes mail). From description you need some loop that periodically checks catalog and extracts new mails. Look at some swing examples in your JDK how to write window-based program with event loop. You can start dedicated thread that once per minute checks POP server catalog



来源:https://stackoverflow.com/questions/8035336/javamail-to-receive-emails-whats-wrong

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!