I have written a wrapper over node-imap(https://github.com/mscdex/node-imap). Currently I am using the since flag to search for emails that arrive in a particular Inbox. For each email that I listen I call upon a imap.search() method and then imap.fetch() method. Is it possible to directly fetch the emails without the imap.search() method. Providing snippets from my current code.
self.imap.on("mail", function(id) {
self.parseUnreadEmails(time)
});
MailListener.prototype.parseUnreadEmails = function(time) {
var self = this;
self.imap.search([["SINCE", time]], function(error, searchResults) {
var fetch;
if (error) {
self.emit("error", error);
} else {
fetch = self.imap.fetch(searchResults, {
bodies: '',
markSeen: true
})
}
//do some action
}
}