IMAP IDLE कमांड और एक्सटेंशन का समर्थन
Contents
[
Hide
]
IMAP Idle कमांड का समर्थन
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");
IMAP एक्सटेंशन का समर्थन
Aspose.Email API IMAP एक्सटेंशन के समर्थन को प्रदान करती है। वर्तमान में API द्वारा निम्नलिखित IMAP एक्सटेंशन समर्थित हैं। ये IMAP एक्सटेंशन सभी सर्वरों द्वारा समर्थित नहीं हैं।
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-Java
final ImapClient client = new ImapClient("imap.gmail.com", 993, "username", "password");
try {
// Set SecurityOptions
client.setSecurityOptions(SecurityOptions.Auto);
System.out.println(client.getIdSupported());
ImapIdentificationInfo serverIdentificationInfo1 = client.introduceClient();
ImapIdentificationInfo serverIdentificationInfo2 = client.introduceClient(ImapIdentificationInfo.getDefaultValue());
// Display ImapIdentificationInfo properties
System.out.println(serverIdentificationInfo1.toString() + serverIdentificationInfo2.toString());
System.out.println(serverIdentificationInfo1.getName());
System.out.println(serverIdentificationInfo1.getVendor());
System.out.println(serverIdentificationInfo1.getSupportUrl());
System.out.println(serverIdentificationInfo1.getVersion());
} finally {
if (client != null)
client.dispose();
}
IMAP4 विस्तारित सूची कमांड
निम्नलिखित कोड स्निपेट दिखाता है कि कैसे IMAP4 विस्तारित सूची कमांड का उपयोग किया जाए।
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-Java
final ImapClient client = new ImapClient("imap.gmail.com", 993, "username", "password");
try {
ImapFolderInfoCollection folderInfoCol = client.listFolders("*");
System.out.println("Extended List Supported: " + client.getExtendedListSupported());
for (ImapFolderInfo folderInfo : (Iterable<ImapFolderInfo>) folderInfoCol) {
if (folderInfo.getName().equals("[Gmail]/All Mail"))
System.out.println("Has Children: " + folderInfo.hasChildren());
if (folderInfo.getName().equals("[Gmail]/Bin"))
System.out.println("Bin has children? " + folderInfo.hasChildren());
if (folderInfo.getName().equals("[Gmail]/Drafts"))
System.out.println("Drafts has children? " + folderInfo.hasChildren());
if (folderInfo.getName().equals("[Gmail]/Important"))
System.out.println("Important has Children? " + folderInfo.hasChildren());
if (folderInfo.getName().equals("[Gmail]/Sent Mail"))
System.out.println("Sent Mail has Children? " + folderInfo.hasChildren());
if (folderInfo.getName().equals("[Gmail]/Spam"))
System.out.println("Spam has Children? " + folderInfo.hasChildren());
if (folderInfo.getName().equals("[Gmail]/Starred"))
System.out.println("Starred has Children? " + folderInfo.hasChildren());
}
} finally {
if (client != null)
client.dispose();
}