Error in Custom Triggered email code

I was creating an email for a form when a site member submitted the form, they get an email. I followed the wix support article about form triggering email. I wrote the code as it was.
I got an error message when I wrote import wixUsers from’wix-users’ ;
I got the error massage on the code import. Could anyone help me out?

Hello Arthur,
how can someone help you, without knowing (see) your code? :roll_eyes:

I couldn’t copy the code for some reason-so I typed it.

import wixUsers from ‘wix-users’ ;
$w.onReady( function () {
$w( “#dataset1” ).onAfterSave( () => {
if (wixUsers.currentUser.loggedIn) {
const userId = wixUsers.currentUser.id;
wixUsers.emailUser( “image” , userId, {
variables: {
“name”: $w(“#nameInput”).value.
}
} )
.then( () => {
// do something after the email was sent successfully } )
.catch( (err) => {
// handle error that prevented the email from being sent
} );
}
} );
} );

As well as the Wix tutorial for sending a triggered email to members, see the emailUser() function in the Wix Users API.
https://www.wix.com/corvid/reference/wix-users.html#emailUser

This simple setup on a site works for me.

import wixUsers from 'wix-users';

$w.onReady(function () {  
  $w("#MembersComments").onAfterSave( () => {
    if(wixUsers.currentUser.loggedIn) {    
      const userId = wixUsers.currentUser.id;
    
      wixUsers.emailUser("CommentsFromMembers", userId, {
          variables: {
            "name": $w("#nameInput").value,
            "reply": $w("#replyBy").value,
            "comments": $w("#commentsInput").value
          }
        } )
        .then( () => {
          // do something after the email was sent successfully
        } )
        .catch( (err) => {
          // handle error that prevented the email from being sent
        } );
    }
  } );
} );

With your code…

import wixUsers from 'wix-users';

$w.onReady(function () {  
  $w("#dataset1").onAfterSave( () => {
    if(wixUsers.currentUser.loggedIn) {    
      const userId = wixUsers.currentUser.id;
    
      wixUsers.emailUser("image", userId, {
          variables: {
            "name": $w("#nameInput").value
          }
        } )
        .then( () => {
          // do something after the email was sent successfully
        } )
        .catch( (err) => {
          // handle error that prevented the email from being sent
        } );
    }
  } );
} );

Make sure that dataset1 is the id name of the dataset element on your page.

No, image is the id for the email that will be triggered.

Lol like yeah of course it should be​:man_facepalming::see_no_evil::woozy_face: think I had too many of these :tumbler_glass::beers::tumbler_glass: before writing the reply and not enough of these :coffee::coffee:

Well at least you spotted it, so well done for that and yes it should be the name of your triggered email :wink:

Like I found a simple spelling mistake in the code😅

There isn’t any error messages in my code. But when I tried the form i didn’t get the email. Do you know why?:thinking: