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

Can't remove, add or set \Seen #232

Open
tarach opened this issue Feb 24, 2020 · 0 comments
Open

Can't remove, add or set \Seen #232

tarach opened this issue Feb 24, 2020 · 0 comments

Comments

@tarach
Copy link

tarach commented Feb 24, 2020

I'm trying to change \Seen flag in an email message but I'm unable to no matter how hard I try ...
I'm using gmail account for testing.

require('dotenv').config();
const config = require('./config');

const ImapClient = require('emailjs-imap-client').default;
const client = new ImapClient(
    config.host,
    config.port,
    config.options
);

const getMessages = async (id) => {
    return await client.listMessages('INBOX', id, ['uid', 'flags', 'body[]']);
};

const printMessages = (messages) => {
    console.log(`Num of messages: ${messages.length}`);
    messages.forEach((message) => {
        if(message.uid === undefined) {
            console.trace(message);
            return null;
        }
        console.log('Flags for ' + message.uid + ': ' + message.flags.join(', '))
    });
};

const main = async () => {
    await client.connect();

    printMessages(await getMessages(7));

    printMessages(await client.setFlags('INBOX', 7, { remove: ['\\Seen']}));

    printMessages(await client.setFlags('INBOX', 7, { remove: ['\Seen'] }));

    printMessages(await getMessages(7));

    await client.close();
};

main().catch(err => console.error(err));

Output:

Num of messages: 1
Flags for 7: \Seen
Num of messages: 1
Trace: { '#': 7, flags: [] }
    at messages.forEach (/f/projects/sms-to-email/index.js:19:21)
    at Array.forEach (<anonymous>)
    at printMessages (/f/projects/sms-to-email/index.js:17:14)
    at main (/f/projects/sms-to-email/index.js:31:5)
    at process._tickCallback (internal/process/next_tick.js:68:7)
Num of messages: 0
Num of messages: 1
Flags for 7: \Seen

I was expecting mail that I'm trying to change to toggle being read/unread in the UI by font from bold normal and vice-versa but nothing happens.

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

1 participant