简体   繁体   English

Gmail的跟踪机制:Java(API)中的IMAP和POP3邮件

[英]Tracking mechanism for Gmail: IMAP and POP3 messages in Java(API)

I am developing an Java application and I want to sync Gmail mails. 我正在开发Java应用程序,并且想要同步Gmail邮件。 What I want exactly is to develop track-mechanism for emails through my app. 我真正想要的是通过我的应用程序开发电子邮件的跟踪机制。 Suppose If in my application I have read messages till current time and suppose its(newest) message ID is msg123. 假设如果在我的应用程序中,我一直阅读到当前时间的消息,并假设其(最新)消息ID为msg123。 After few time, if in my inbox new messages are arrived. 几天后,如果在我的收件箱中收到新邮件。 I want to read only those newly arrived mails. 我只想阅读那些新收到的邮件。 Like if new messages have ID msg124, msg125 and msg126. 就像新消息具有ID msg124,msg125和msg126一样。 I want to read only those messages that have messages ID - msg124, msg125 and msg126. 我只想读取具有消息ID的消息-msg124,msg125和msg126。

So my questions are: 所以我的问题是:

1. If I am connected to Gmail using POP3/IMAP server using credentials is it possible to query only those emails that are newer than last read mail time-stamp ? 1.如果使用凭据通过POP3 / IMAP服务器连接到Gmail,是否可以仅查询比上次阅读邮件时间戳新的电子邮件?

2. In my search I found this link which states that with OAuth we can achieve mail tracking(As what I want). 2.在我的搜索中,我发现此链接指出,使用OAuth,我们可以实现邮件跟踪(如我所愿)。 Docs ref link Gmail API . 文档参考链接Gmail API Please suggest me if I am in wrong direction. 如果我的方向错误,请提出建议。

OAuth has nothing to do with this problem, and the Gmail API won't make this any easier. OAuth与此问题无关,并且Gmail API不会使此操作变得更简单。

You really need to learn about IMAP UIDs, exposed in JavaMail through the UIDFolder interface , which IMAP folders implement. 您确实需要了解通过IDF文件夹实现的UIDFolder接口在JavaMail中公开的IMAP UID。

If you keep track of the last UID you processed, you can query for UIDs larger than that using the UIDFolder.getMessagesByUID method . 如果跟踪上一个处理的UID,则可以使用UIDFolder.getMessagesByUID方法查询大于UID的UID。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM