# Triggered Email not sent

**URL:** <https://forum.wixstudio.com/t/triggered-email-not-sent/68863>\
**Category:** Ask the community\
**Tags:** code, question, wix\
**Created:** [February 18, 2025, 4:47pm UTC](https://forum.wixstudio.com/t/triggered-email-not-sent/68863 "2025-02-18T16:47:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mairie\_MAILLY\_LE\_CHA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/mairie_mailly_le_cha/32/97985_2.png) [@Mairie\_MAILLY\_LE\_CHA](https://forum.wixstudio.com/u/Mairie_MAILLY_LE_CHA)\
**Post date:** [February 18, 2025, 4:47pm UTC](https://forum.wixstudio.com/t/triggered-email-not-sent/68863/1 "2025-02-18T16:47:22Z")

</div>

**Question:**

Hello everyone

I created 2 “triggered emails” which must be sent to a very specific customer in my database at 2 very specific times: after registration and after validation of their reservation.  
When the customers enters their data, they are saved in a collection called “Mes Clients”. At this time, I would like this same customer to receive the triggered email that I named: **“EnregistrementValide”**. (to the email saved in “MesClients” Collection corresponding)  
My PB: customer data is well recorded in my “MyClients” collection(mail, LAstName, Firstname, etc…) , but the email is not sent to them.  
Can you help me please?

_My (important) fields :_

- lastName
- firstName
- email
- EnvoiMailClt : My dataset (MesClients)

P.S : i watched some videos on the web and i found some solutions : but don’t work, and i don’t really understand them.

Thank you in advance

**Product:**  
Wix EDITOR

**What are you trying to achieve:**  
Send a triggered email.

\*\*Here the code i use : \*\*

> $w(“#EnvoiMailClt”).onReady(() =\> {  
> $w(“#EnvoiMailClt”).onAfterSave(() =\> {
> 
> ```
> wixCRM.createContact({
> "firstName": $w('#firstName').value,
> "lastName": $w("#lastName").value,
> "emails": [$w("#email").value]
> 
> }).then((contactId) => {
> 
> triggeredEmails.emailContact('EnregistrementValide', contactId, {
> variables: {
> firstName: session.getItem("firstName"),
> lastName: session.getItem("lastName"),
> email: session.getItem("email")
> 
> }
> });
> });
> //
> });
> 
> //$w("#firstName, #lastName, #email").onInput(() => {
> session.setItem("firstName", $w("#firstName").value)
> session.setItem("lastName", $w("#lastName").value)
> session.setItem("email", $w("#email").value)
> //})
> 
> ```
> 
> })

---

<div class="post-metadata">

**Author:** ![docmalc](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/docmalc/32/12292_2.png) [@docmalc](https://forum.wixstudio.com/u/docmalc)\
**Post date:** [February 18, 2025, 7:00pm UTC](https://forum.wixstudio.com/t/triggered-email-not-sent/68863/2 "2025-02-18T19:00:48Z")

</div>

If your email is using an NPM then its because all the npm’s are down across Wix.

---

<div class="post-metadata">

**Author:** ![Mairie\_MAILLY\_LE\_CHA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/mairie_mailly_le_cha/32/97985_2.png) [@Mairie\_MAILLY\_LE\_CHA](https://forum.wixstudio.com/u/Mairie_MAILLY_LE_CHA)\
**Post date:** [February 18, 2025, 7:54pm UTC](https://forum.wixstudio.com/t/triggered-email-not-sent/68863/3 "2025-02-18T19:54:55Z")

</div>

Thanks.  
Effectively, i used to send mails by sendgrid (It worked fine), but since a few weeks, thats is not possible anymore. … So i try to use triggered emails.  
So… what to do?

---

<div class="post-metadata">

**Author:** ![docmalc](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/docmalc/32/12292_2.png) [@docmalc](https://forum.wixstudio.com/u/docmalc)\
**Post date:** [February 18, 2025, 8:22pm UTC](https://forum.wixstudio.com/t/triggered-email-not-sent/68863/4 "2025-02-18T20:22:36Z")

</div>

I’m not sure what ‘triggered emails’ you’re referring to so not sure how to help.  
I heavily rely on sendgrid npm’s so this Wix issue is hurting. I built a ‘fetch’ work around as a bandaid.

Edit: Nevermind, I see from your code you’re using Wix CRM backend which I’m not familiar with. Perhaps the issue Wix is having with npms is affecting that as well? Not sure.

---

<div class="post-metadata">

**Author:** ![codequeen](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/codequeen/32/88960_2.png) [@codequeen](https://forum.wixstudio.com/u/codequeen)\
**Post date:** [February 19, 2025, 6:10am UTC](https://forum.wixstudio.com/t/triggered-email-not-sent/68863/5 "2025-02-19T06:10:05Z")

</div>

Is it creating the contact at all?

You are trying to create after the dataset saves —— at which point anything connected to a dataset input will get reset and erased.

Ao the logic order of your code is mixed up.

OnBefore save, validate that all required inputs have been filled out, then create contact, then save form, send trigger email. You can pass the variables you need within the chain of code. You don’t need to be using storage.

> **[Append Or Create Contact | Velo](https://dev.wix.com/docs/velo/api-reference/wix-crm-frontend/contacts/append-or-create-contact)**
>
> Appends an existing contact or creates a contact if it doesn't exist. The appendOrCreateContact() function returns a Promise

> **[Email Contact | Velo](https://dev.wix.com/docs/velo/api-reference/wix-crm-frontend/triggered-emails/email-contact)**
>
> Sends a triggered email to the current contact, unless that contact is marked as unsubscribed. To learn more about Triggered Emails, see:

---

<div class="post-metadata">

**Author:** ![Mairie\_MAILLY\_LE\_CHA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/mairie_mailly_le_cha/32/97985_2.png) [@Mairie\_MAILLY\_LE\_CHA](https://forum.wixstudio.com/u/Mairie_MAILLY_LE_CHA)\
**Post date:** [February 26, 2025, 9:08am UTC](https://forum.wixstudio.com/t/triggered-email-not-sent/68863/6 "2025-02-26T09:08:42Z")

</div>

Thanks a lot for you help
