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