Hỗ trợ Lệnh IMAP IDLE

Contents
[ ]

API Aspose.Email ImapClient cung cấp khả năng mở kết nối tới máy chủ và chờ đợi sự xuất hiện của một tin nhắn email. Điều này cho phép tránh việc liên tục truy vấn máy chủ để kiểm tra email mới tới. Đoạn mã sau cho bạn thấy cách Hỗ trợ Lệnh 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");