【发布时间】:2021-06-03 22:45:27
【问题描述】:
早上好,我在工作中使用这个库,但遇到了问题。
当我连接到 imapflow 邮件服务器时,它会返回所有邮件,但我无法区分哪些邮件已读,哪些未读。
我一直在阅读文档 (https://imapflow.com/),但找不到任何对我有帮助的东西。我也尝试过使用过滤器,但没有任何效果。
你能帮帮我吗?
我将代码 sn-p 留在我试图获取未读电子邮件的位置。
非常感谢您的帮助。
const main = async (client) => {
let envelope = [];
await client.connect();
// At this point I have set the variable unseen to true but it doesn't work :(
let lock = await client.getMailboxLock('INBOX', {unseen: true});
try {
let message = await client.fetchOne('*', { source: true });
//console.log(message.source.toString());
for await (let message of client.fetch('1:*', { envelope: true })) {
envelope.push(message.envelope)
}
} finally {
lock.release();
}
await client.logout();
let reverse_envelope = envelope.reverse();
return reverse_envelope
};
【问题讨论】:
-
我不知道这个库,但是关于消息的元数据包含在“FLAGS”获取项中。 \Seen 告诉您它是否已被阅读,\Flagged 如果用户将其标记为重要,等等。