# Need to get a ContactID from the contacts email address

**URL:** <https://forum.wixstudio.com/t/need-to-get-a-contactid-from-the-contacts-email-address/42086>\
**Category:** Ask the community\
**Tags:** question, code\
**Created:** [May 21, 2021, 9:28pm UTC](https://forum.wixstudio.com/t/need-to-get-a-contactid-from-the-contacts-email-address/42086 "2021-05-21T21:28:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sheldonl](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/sheldonl/32/28448_2.png) [@sheldonl](https://forum.wixstudio.com/u/sheldonl)\
**Post date:** [May 21, 2021, 9:28pm UTC](https://forum.wixstudio.com/t/need-to-get-a-contactid-from-the-contacts-email-address/42086/1 "2021-05-21T21:28:58Z")

</div>

Hello,

I’m trying to create an http-function to send a triggered email to a customer contact, **not** a member. The input I have is the contacts email address. Can someone please point me in the direction of the correct API to use to do this?

I have the code to send the triggered email, the only thing I’m missing is how to get the Id of the contact to send it to.

```javascript
let ContactID = ??? HOW DO I GET THIS?

wixCrmBackend.emailContact(form, contactID)
                .then ( () => {
                    console.log("Triggered email sent");
                })
                .catch( (err) => {
                    console.log(err);
                });

```

---

<div class="post-metadata">

**Author:** ![bwprado](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/bwprado/32/7220_2.png) [@bwprado](https://forum.wixstudio.com/u/bwprado)\
**Post date:** [May 22, 2021, 12:42am UTC](https://forum.wixstudio.com/t/need-to-get-a-contactid-from-the-contacts-email-address/42086/2 "2021-05-22T00:42:39Z")

</div>

Hello friend.

You need to create a function to find the contact for you, either with name or email as a search parameter, for example:

```javascript
import { contacts } from 'wix-crm-backend'

async function findContactIdByEmail(email) {
 const queryResults = await contacts.queryContacts()
        .eq("info.emails.email", email)
        .find()
 const contactsFound = queryResults.items
 return contactsFound[0]._id // This will return the first ContactID found with the email providaded
}

```

* * *

This function will provide the first ContactID found with the email provided.

To use this function, you just need to do something like this:

let contactId = findContactIdByEmail(“[sheldonlee@wix.com](mailto:sheldonlee@wix.com)”)

---

<div class="post-metadata">

**Author:** ![sheldonl](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/sheldonl/32/28448_2.png) [@sheldonl](https://forum.wixstudio.com/u/sheldonl)\
**Post date:** [May 22, 2021, 6:50pm UTC](https://forum.wixstudio.com/t/need-to-get-a-contactid-from-the-contacts-email-address/42086/3 "2021-05-22T18:50:09Z")

</div>

Thanks!
