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