Trying to delete mail using node-imap

大憨熊 提交于 2019-12-20 01:52:45

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!