mark an email as "read"
Closed this issue · 7 comments
Que20 commented
Is there a way to mark an email as "read" ?
chirag04 commented
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.
});
Que20 commented
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...?
chirag04 commented
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.
Que20 commented
That's exactly what I wanted ! Thank you 👍
sureshballa commented
How do we get uid?
sureshballa commented
I tried using attributes.uid. It works on one machine but not in another one :(
chickenCabbage commented
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.