Replace in unread emails

Hello. The function works great only for one unread email in Gmail. If there are more than one unread letters, then an empty message is left in the next element. Please tell me, I’ve tried a lot of code variants and it doesn’t work.

Here’s a function that works for one unread email:

const item = $node[“Получить новые письма”].json[“text”];
items[0].json.cuttext = item.replace(/<.+>/g, “”);
return items;

Here the nodes:

This should iterates over all incoming items and run the replace:

items.forEach(item => {
  item.json.cuttext = item.json.text.replace(/<.+>/g, "");
});

return items;
1 Like

Thank you, comrade! I read earlier that n8n has a friendly community. Now I am convinced of this!

Happy to hear that I could help and that what you did hear matches reality.

Have fun!