# Provide search criteria to IMAP on email node on trigger

**URL:** <https://discourse.nodered.org/t/provide-search-criteria-to-imap-on-email-node-on-trigger/11642>\
**Category:** Feature Requests\
**Created:** [28 May 2019 16:23 UTC](https://discourse.nodered.org/t/provide-search-criteria-to-imap-on-email-node-on-trigger/11642 "2019-05-28T16:23:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![domenzain](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/domenzain/32/8554_2.png) [@domenzain](https://discourse.nodered.org/u/domenzain)\
**Post date:** [28 May 2019 16:23 UTC](https://discourse.nodered.org/t/provide-search-criteria-to-imap-on-email-node-on-trigger/11642/1 "2019-05-28T16:23:52Z")

</div>

The `node-red-node-email` allows an e-mail fetch to be triggered. But the search criteria are limited to just a few including "Seen", "Unseen", "All".

It would be great to be able to pass the criteria directly when triggering as described in the underlying `imap-node`:

> **[mscdex/node-imap](https://github.com/mscdex/node-imap)**
>
> An IMAP client module for node.js. Contribute to mscdex/node-imap development by creating an account on GitHub.

Like this, it would be possible to fetch all messages in the `References` header on an already fetched e-mail, for example.  
Or to get all read messages without replies that include `.patch` files...  
The criteria can be as general or as precise as needed.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [28 May 2019 16:27 UTC](https://discourse.nodered.org/t/provide-search-criteria-to-imap-on-email-node-on-trigger/11642/2 "2019-05-28T16:27:13Z")

</div>

As you have already provided us with other Pull requests... don't stop now 🙂

What we have done previously (in other nodes) is add to a select [- set by msg.foo -] where foo would be search or criteria or something useful... and once set that way the criteria would be allowed to be passed in, which is presumably what you wish to do.

Happy to discuss.

---

<div class="post-metadata">

**Author:** ![domenzain](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/domenzain/32/8554_2.png) [@domenzain](https://discourse.nodered.org/u/domenzain)\
**Post date:** [29 May 2019 09:09 UTC](https://discourse.nodered.org/t/provide-search-criteria-to-imap-on-email-node-on-trigger/11642/3 "2019-05-29T09:09:35Z")

</div>

Here's a proposal:

> <https://github.com/node-red/node-red-nodes/pull/547>

I have tried this in a flow where node-RED fetches unread e-mails, downloads some linked files with credentials provided in them and replies to them with the files attached before marking them as read (by setting the criteria to match the `message-id` header of the original e-mail).

This is useful for many services that say "your monthly statement is now available at our company's portal, please log-in to see it".
