如何从 Java 应用程序访问我的 Gmail 电子邮件?
我想从 Java 代码中获取我的 Gmail 帐户的电子邮件。我该怎么做呢?
I want to fetch the emails of my gmail account from Java code. How can I go about doing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这是刷新工作代码,它以正确的格式在控制台中显示电子邮件消息以及正在下载的附件......
Here is the Refresh Working Code, that Displays the Email msgs in the console in a proper format along with the Attachments also being Downloaded....
另一种选择:如果您不介意它是特定于 Gmail 的解决方案,请注意 Gmail 还向您的邮箱提供 RSS 提要,然后您可以使用普通的 XML 处理 API 进行访问。
Another option: if you don't mind it being a Gmail-specific solution, note that Gmail also provides an RSS feed to your mailbox, which you can then access with normal XML processing APIs.
Gmail 使用 IMAP,Javamail 可以使用 IMAP。尝试在实现中使用它,如果您遇到困难,请在此处发布一些更具体的问题。
Gmail uses IMAP, which Javamail can use. Try to use that in an implementation, and if you get stuck, post some more specific questions here.
下面是使用邮局协议 (pop3) 从 gmail 帐户获取邮件及其附件(如果有)的代码。
要运行这个java类,您需要下载 javamail.jar 和 < a href="http://www.java2s.com/Code/Jar/JKL/Downloadactivationjar.htm" rel="nofollow noreferrer">activation.jar
Here is the code which fetch mail along with it's attachments (if any) from a gmail account using POST OFFICE PROTOCOL (pop3) .
To run this java class you need to download javamail.jar and activation.jar