Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete email messages #47

Closed
AndreLigeiro opened this issue Feb 12, 2012 · 7 comments
Closed

Delete email messages #47

AndreLigeiro opened this issue Feb 12, 2012 · 7 comments

Comments

@AndreLigeiro
Copy link

Hi,

How can I delete an email?
What I'm doing wrong?
Thks.

fetch = imap.fetch(req.params.id, {request: {headers:true, body:false } });

            fetch.on('message', function(msg)
            {
                msg.on('end', function() {
                    console.log("Flags: " + msg.flags);
                    msg.flags.push("\\Deleted");
                    console.log("Flags: " + msg.flags);
                });         
            });

            fetch.on('end', function()
            {
                imap.logout(cb);
                imap.closeBox(function(err) {
                if (err)
                    console.log(err);});

}

@mscdex
Copy link
Owner

mscdex commented Feb 12, 2012

You should be closing the box first before logging out.

@AndreLigeiro
Copy link
Author

I try that but it not works. Any other suggestion?

@mscdex
Copy link
Owner

mscdex commented Feb 13, 2012

Oops, overlooked the part where you were adding the flag. Here's the simplest way to delete a message and then log out:

imap.addFlags(req.params.id, 'Deleted', function(err) {
  if (err) return cb(err);
  imap.closeBox(function(err) {
    if (err) return cb(err);
    imap.logout(cb);
  });
});

@AndreLigeiro
Copy link
Author

Thanks a lot. :)

@mscdex mscdex closed this as completed Feb 13, 2012
@bitraft
Copy link

bitraft commented Apr 30, 2013

I use the node 0.10.5 , imap@0.7.11. yahoo email ssl:993. get this error:

Error: The flag "Deleted" is not allowed by the server for this mailbox

@bitraft
Copy link

bitraft commented Apr 30, 2013

imap._state.box.permFlags is empty.

@aaronbriel
Copy link

@AndreLigeiro Would it be possible to show how you initialized 'req' here? I'm trying to achieve something similar but I'm unsure of what object would have the params.id. I do a call like 'f.on('message', function(msg, seqno) {' but msg doesn't seem to have it. I'm trying to build off of the example listed in https://github.com/mscdex/node-imap

Thanks!!

Jivings added a commit to squarecat/node-imap that referenced this issue Nov 6, 2019
fix(open): this months revenue not showing subs revenue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants