问题
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?
回答1:
imap.setFlags()
works with UIDs. imap.seq.setFlags()
works with sequence numbers. Since it seems like you're trying to pass a sequence number, you should use the latter function instead.
来源:https://stackoverflow.com/questions/39430091/trying-to-delete-mail-using-node-imap