Closed Loufi1 closed 3 years ago
You can use an event that allows you to handle the arrival of new emails.
imaps.connect(config).then(function (connection) {
connection.on('mail', () => {
const searchCriteria = [
'UNSEEN'
];
const fetchOptions = {
bodies: ['HEADER', 'TEXT'],
markSeen: false
};
connection.search(searchCriteria, fetchOptions).then(function (messages) {
messages.forEach(function (item) {
console.log('item', item)
});
});
})
return connection.openBox('INBOX')
})
Hello,
I'm looking for a way to retrieve the content of the mail who triggered the onMail event. Is there a way to do it ?