I have a dummy gmail address I created to write a unit test for a component that reads and processes email. Before the test I want to mark all emails read, and then specific emails unread. However unfortunately addFlags() does not seem to be working for me.
I may also be misunderstanding the documentation; if so an example would be very helpful!
Simplified example of what I'm trying:
async.auto({
openInbox: [function(next) {
imap.openBox('[Gmail]/All Mail', next);
}],
searchUnread: ['openInbox', function(next) {
imap.search(['UNSEEN'], next);
}],
markAllRead: ['searchUnread', function(next, results) {
var unreadUids = results.searchUnread;
imap.addFlags(unreadUids, ['\\Seen'], next);
/* also tried '\\SEEN' and 'SEEN' */
}],
markTestEmailsUnread: ['markAllRead', function(next) {
imap.delFlags(testEmailUids, ['\\Seen'], next);
/* note: testEmailUids is an array like [3,7] -- the UIDs of specific emails */
}],
closeInbox: ['markTestEmailsUnread', function(next) {
imap.closeBox(next);
}]
}, function(err) {
eachNext(err);
});
The code executes fine without throwing or calling back any errors. However the emails are never marked as read in gmail.
I have a dummy gmail address I created to write a unit test for a component that reads and processes email. Before the test I want to mark all emails read, and then specific emails unread. However unfortunately addFlags() does not seem to be working for me.
I may also be misunderstanding the documentation; if so an example would be very helpful!
Simplified example of what I'm trying:
The code executes fine without throwing or calling back any errors. However the emails are never marked as read in gmail.