How to automatically get new mails from gmail account using java?

巧了我就是萌 提交于 2019-12-11 16:53:46

问题


I know my question is more likely to be discussed rather than really answered (because it's very large), but I need some elements and "advices" to really get started, sorry for that.

So I've got a java program which has to analyse some URLs, I've finished this part. For the moment, the user has to enter manually the link into my program, then the link is analysed.

Now I have to retrieve automatically those links, which will be sent to me via e-mail. (In a special Gmail inbox created for that purpose)

So I need to :

  • Let my Java program "listen" to my inbox
  • Extract the link of any new mail in order to analyse it

There are many problems, according to the way I choose to access to my inbox (POP3, GMail API...), according to the frequency my application would check the inbox, maybe there would be authentification problems... Even how to let my application run as a "daemon"...

And I really don't know how to get started, which choices to make etc.

Any help is welcome of course, if you have any documentation or else. Thank you in advance.


回答1:


You have several ways of doing this.

I suggest you using Java Mail, that has a simple and useful API.

You have some documentation and examples in this URL:

https://java.net/projects/javamail/pages/Home#Samples

Look at the class monitor (very bad name!!!) inside the examples. This class monitor a mail box for new emails.



来源:https://stackoverflow.com/questions/29968090/how-to-automatically-get-new-mails-from-gmail-account-using-java

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