# Unable to get trigger email working at all

**URL:** <https://forum.wixstudio.com/t/unable-to-get-trigger-email-working-at-all/63706>\
**Category:** Ask the community\
**Tags:** wix-studio, question, code, wix-members-area\
**Created:** [October 18, 2024, 5:03pm UTC](https://forum.wixstudio.com/t/unable-to-get-trigger-email-working-at-all/63706 "2024-10-18T17:03:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![user3542](https://avatars.discourse-cdn.com/v4/letter/u/90ced4/32.png) [@user3542](https://forum.wixstudio.com/u/user3542)\
**Post date:** [October 18, 2024, 5:03pm UTC](https://forum.wixstudio.com/t/unable-to-get-trigger-email-working-at-all/63706/1 "2024-10-18T17:03:50Z")

</div>

**Question:**  
Unable to get trigger emails working at all

**Product:**  
WixEditor/Velo  
**What are you trying to achieve:**  
[Explain the details of what you are trying to achieve. The more details you provide, the easier it is to understand what you need.]

**What have you already tried:**  
Multiple walkthroughs and instruction guides

> **[Sending a Triggered Email to Members](https://dev.wix.com/docs/develop-websites/articles/workspace-tools/developer-tools/triggered-emails/sending-a-triggered-email-to-members)**
>
> Triggered Emails allow you to create a template for emails that you can send to the currently logged-in site member, using code. Before sending the email, your code can inject information into the template to personalize it with any data that is...

**Additional information:**  
I constantly get the error the following error:

```javascript
email error Not Found: the requested item no longer exists.

```

Item exists in dataset:  
 ![image](https://us1.discourse-cdn.com/wix/original/3X/a/3/a3fb4f5369b251c5f8283f2dd7f3f2697decef63.png)

Logs from running in preview:

```javascript
succesful save of site member in dataset
member exists, send email
email error Not Found: the requested item no longer exists.

```

Trigger email snippet:

```javascript
triggeredEmails.emailMember('Enquire', <enter-member-id-here>, {
  variables: {
        email: <enter-value-here>,
        SITE_URL: <enter-value-here>
  }
});

```

My code snippet:

```javascript
import { triggeredEmails } from "wix-crm-frontend";
import { currentMember } from "wix-members-frontend";

$w.onReady(function () {
    $w("#submit").onClick(async () => {
        $w("#siteMembersConnect").onAfterSave(async () => {
            console.log('succesful save of site member in dataset')
            const member = await currentMember.getMember();
            if (member) {
                console.log('member exists, send email')
                const userId = member._id;
                triggeredEmails
                    .emailMember("Enquire", userId, {
                        variables: {
                            email: $w("#email").value,
                        },
                    })
                    .then(() => {
                        console.log('email sent')
                    })
                    .catch((err) => {
                        console.error('email error', err)
                    });
            }
        });
    });
});

```

---

<div class="post-metadata">

**Author:** ![onemoretime](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/onemoretime/32/104023_2.png) [@onemoretime](https://forum.wixstudio.com/u/onemoretime)\
**Post date:** [October 22, 2024, 12:26am UTC](https://forum.wixstudio.com/t/unable-to-get-trigger-email-working-at-all/63706/2 "2024-10-22T00:26:17Z")

</div>

Hi, user3542 !!

Is that email address correct? It seems to be missing the “@” symbol. 🤔

---

<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:** [October 22, 2024, 1:39am UTC](https://forum.wixstudio.com/t/unable-to-get-trigger-email-working-at-all/63706/3 "2024-10-22T01:39:21Z")

</div>

Out of curiosity, do you have your Submit button connected to a dataset?

If yes, then you cannot add code in the code panel to trigger anything onClick. You either code the button OR connect the button but not both.

Also, onAfterSave is not triggered by a button click. It is triggered after a dataset gets saved. So move it out of the “onclick” button code you currently have it under.

And lastly, the variable for the email input is set to the email input value. Any input that is connected via a dataset will erase itself after a dataset saves itself—— that means the value will be empty. So you need to create a variable of the item that was saved and retrieve the email value to insert it into your variables section.

---

<div class="post-metadata">

**Author:** ![user3542](https://avatars.discourse-cdn.com/v4/letter/u/90ced4/32.png) [@user3542](https://forum.wixstudio.com/u/user3542)\
**Post date:** [October 22, 2024, 1:33pm UTC](https://forum.wixstudio.com/t/unable-to-get-trigger-email-working-at-all/63706/4 "2024-10-22T13:33:40Z")

</div>

Sorry that was an older screenshot from testing, but the wrong one in, the @ symbol is present

---

<div class="post-metadata">

**Author:** ![user3542](https://avatars.discourse-cdn.com/v4/letter/u/90ced4/32.png) [@user3542](https://forum.wixstudio.com/u/user3542)\
**Post date:** [October 22, 2024, 1:34pm UTC](https://forum.wixstudio.com/t/unable-to-get-trigger-email-working-at-all/63706/5 "2024-10-22T13:34:10Z")

</div>

Amazing thank you for the feedback, i’ll double check those solutions later today and see how we get on :+1:
