IMAP IDLE コマンドのサポート

Contents
[ ]

Aspose.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");