如何使用Java从Gmail帐户自动获取新邮件? [英] How to automatically get new mails from gmail account using java?

查看:209
本文介绍了如何使用Java从Gmail帐户自动获取新邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我的问题更有可能讨论而不是真正回答(因为问题很大),但是我需要一些要素和建议"才能真正上手,对此表示歉意.

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.

因此,我有一个必须分析某些URL的Java程序,我已经完成了这一部分.目前,用户必须将链接手动输入到我的程序中,然后分析链接.

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.

现在,我必须自动检索那些链接,这些链接将通过电子邮件发送给我. (在为此目的创建的特殊Gmail收件箱中)

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)

所以我需要:

  • 让我的Java程序收听"我的收件箱
  • 提取任何新邮件的链接以对其进行分析

根据我选择访问我的收件箱的方式(POP3,GMail API ...),有很多问题,根据我的应用程序检查收件箱的频率,也许会出现身份验证问题...甚至如何让我的应用程序作为守护程序"运行...

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.

推荐答案

您有几种方法可以做到这一点.

You have several ways of doing this.

我建议您使用Java Mail,该API具有简单实用的API.

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

此URL中包含一些文档和示例:

You have some documentation and examples in this URL:

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

查看示例中的类monitor(非常糟糕的名字!!).此类监视邮箱中是否有新电子邮件.

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

这篇关于如何使用Java从Gmail帐户自动获取新邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆