ImapClient का असिंक्रोनस रूप से उपयोग करना
Contents
[
Hide
]
संदेशों को Aspose.Email का उपयोग करके असिंक्रोनस रूप से मेलबॉक्स से प्राप्त किया जा सकता है। ImapClient. यह लेख असिंक्रोनस रूप से मेलबॉक्स से संदेशों को प्राप्त करने को दर्शाता है। यह लेख यह भी दिखाता है कि खोज मानदंड प्रदान करके संदेशों को सूचीबद्ध कैसे किया जाए, उपयोग करके MailQuery.
संदेशों को असिंक्रोनस रूप से प्राप्त करें
निम्नलिखित कोड स्निपेट दिखाता है कि संदेशों को असिंक्रोनस रूप से कैसे प्राप्त किया जाए।
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-Java
// Connect and log in to IMAP
try (ImapClient client = new ImapClient("host", "username", "password")) {
client.selectFolder("Issues/SubFolder");
ImapMessageInfoCollection messages = client.listMessages();
IAsyncResult ar = client.beginFetchMessage(messages.get_Item(0).getSequenceNumber());
MailMessage message = client.endFetchMessage(ar);
}
MailQuery के साथ संदेशों को असिंक्रोनस रूप से सूचीबद्ध करें
यह MailQuery क्लास को असिंक्रोनस रूप से निर्दिष्ट सूची के संदेशों को पुनः प्राप्त करने के लिए खोज मानदंड निर्दिष्ट करने हेतु उपयोग किया जा सकता है, जैसा कि निम्नलिखित कोड नमूने में दिखाया गया है।
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-Java
ImapQueryBuilder builder = new ImapQueryBuilder();
builder.getSubject().contains("Subject");
MailQuery query = builder.getQuery();
IAsyncResult asyncResult = client.beginListMessages(query);
ImapMessageInfoCollection messages = client.endListMessages(asyncResult);