chirag04/mail-listener2

mark an email as "read"

Closed this issue · 7 comments

Is there a way to mark an email as "read" ?

Use the markseen option. eg:

var mailListener = new MailListener({
  username: "imap-username",
  password: "imap-password",
  host: "imap-host",
  port: 993, // imap port
  tls: true,
  tlsOptions: { rejectUnauthorized: false },
  mailbox: "INBOX", // mailbox to monitor
  searchFilter: "UNSEEN", // the search filter being used after an IDLE notification has been retrieved
  markSeen: true, // all fetched email willbe marked as seen and not fetched next time
  fetchUnreadOnStart: true, // use it only if you want to get all unread email on lib start. Default is `false`,
  mailParserOptions: {streamAttachments: true} // options to be passed to mailParser lib.
});

Hi, thank you for the reply, but there isn't a way to mark a specific email as read ? Not all of the ones that are listed...?

You can do:

mailListener.imap. addFlags(uid, '\\Seen', function(err) {
     if(!err) {
           console.log('mail marked as read');
     }
});

You will need the uid of the mail you want to mark as read.

That's exactly what I wanted ! Thank you 👍

How do we get uid?

I tried using attributes.uid. It works on one machine but not in another one :(

I tried to mark an email as unseen using this piece:

mailListener.imap.addFlags(attributes.uid, 'UNSEEN', function(err) {
	if(!err) console.log('mail marked as unread');
	else throw err;
});

It does not recognize any flag that I gave it. I tried 'Unseen', '(Unseen)', '(\Unseen)', and '(Unseen)' with different capital letter variations, none worked.