我正在尝试使用 subscribeToPullNotifications 检测收件箱中的新电子邮件,如下所示:
PullSubscription subscription = service.subscribeToPullNotifications(
folder, 1, null, EventType.NewMail);
GetEventsResults events = subscription.getEvents();
System.out.println("####### EVENTS: "
+ events.getItemEvents().toString());
for (ItemEvent itemEvent : events.getItemEvents()) {
if (itemEvent.getEventType() == EventType.NewMail) {
EmailMessage message = EmailMessage.bind(service,
itemEvent.getItemId());
System.out.println("######## NEW EMAIL MESSAGE IS: "
+ message.getSubject());
}
}
但events.getItemEvents()
始终是空的,即使我可以在收件箱中看到新电子邮件。此外,如何在应用程序运行时始终重复上述代码,以便每分钟检查新电子邮件。