支持 IMAP IDLE 命令
Contents
[
Hide
]
Aspoe.Email API ImapClient 提供打开到服务器的连接并等待电子邮件到达的功能。这可以避免一次又一次地轮询服务器以获取任何传入的电子邮件。下面的代码片段展示了如何支持 IMAP Idle 命令。
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-Java
// Connect and log in to IMAP
ImapClient client = new ImapClient("imap.domain.com", "username", "password");
client.startMonitoring(new ImapMonitoringEventHandler() {
public void invoke(Object sender, ImapMonitoringEventArgs e) {
System.out.println(e.getNewMessages().length);
System.out.println(e.getDeletedMessages().length);
}
});
client.stopMonitoring("Inbox");