Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to mark unseen email as seen with node-imap in node.js

Tags:

node.js

imap

i want to recieve email and mark email unseen as seen with node-imap. the recieving i have done, but i don't know how to mark email unseen as seen. the API offers a function seems like replace the code var f = imap.fetch(results, { bodies: '' }); with var f = imap.fetch(results, { markSeen : true });in the example,but it seems doesn't work. what should i do?

like image 549
MarsOnly Avatar asked Nov 14 '25 16:11

MarsOnly


2 Answers

oh, i'va got solution. it's my fault to open mailbox in read-only mode, that's why i couldn't modify the mail's status.imap.openBox('INBOX', false, cb); the second args false means open mailbox not in read-only mode.

like image 87
MarsOnly Avatar answered Nov 17 '25 09:11

MarsOnly


I tried setting mail status to false imap.openBox('INBOX', false, cb) but it didn't work at first.

But then I changed the data in body and set it to HEADER.FIELDS (FROM TO SUBJECT DATE) it worked. I don't know how is this related but it's working now while the mail box read-only status is false obviously.

Non working code:

imap.fetch(results, { bodies: '', markSeen: true });

Working code:

imap.fetch(results, { bodies: 'HEADER.FIELDS (FROM TO SUBJECT DATE)', markSeen: true });
like image 43
Kazim Homayee Avatar answered Nov 17 '25 09:11

Kazim Homayee