Closed chetanpatel6 closed 4 years ago
What does your call to .openBox()
look like?
//Readonly mode was True function openInbox(cb) { imap.openBox('INBOX', true, cb); }
//And I changed it to false function openInbox(cb) { imap.openBox('INBOX', false, cb); }
//Now it is working //Thankyou
imap.search(['UNSEEN', ['SINCE', 'July 1, 2020']], function (err, results) { if (err) throw err; var f = imap.fetch(results, { bodies: '' ,markSeen:true}); var newMails = []; f.on('message', function (msg, seqno) { var mailFields = { subject: "", date: "", name: "", email: "", text: "" } msg.on('body', function (stream, info) { // use a specialized mail parsing library (https://github.com/andris9/mailparser)
simpleParser(stream, (err, mail) => { var from = mail.from.text; var address = parser(from); mailFields.subject = mail.subject; mailFields.date = mail.date; mailFields.name = address[0].name; mailFields.email = address[0].address; mailFields.text = mail.text; // console.log(mail.from.text); // console.log(mail.subject); // console.log(mail.date) // console.log(address[0].name); // console.log(address[0].address); // console.log(prefix + mail.text); });
}