Trying to delete email in node.js using node-imap module.
I open the INBOX in read/write mode:
imap.openBox('INBOX', false, cb);
I then fetch all the messages:
var f = imap.seq.fetch("1:"+box.messages.total, {
bodies: ['HEADER.FIELDS (FROM TO SUBJECT DATE)','TEXT'],
struct: true
});
I flag the mail to be deleted:
msg.on('end', function() {
imap.seq.addFlags(seqno, '\\Deleted', function(err) { } );
});
I close the mailbox with autopurge set to true
imap.closeBox(true);
But this doesn't work. What am I doing wrong?