So, I have tried this every which way to Sunday and cannot see why it is not working.
I followed the Corvid tutorial on setting up and sending a triggered email. Check.
I created my triggered email template. Check.
I have all the variables and inputs set up on the page as they work successfully with other bits of the page. Check.
I coded the logged-in member button with an onClick:
import wixUsers from 'wix-users';
let userId = wixUsers.currentUser.id;
export function emailButton_click(event) {
$w.onReady(function () {
if(wixUsers.currentUser.loggedIn) {
wixUsers.emailUser('SCsix8E', userId, {
variables: {
"fkHeading1": $w("#fkHeading1").text,
"comQTY1": $w("#comQTY1").value,
"passedPrice1": $w("#passedPrice1").text,
"passedCodeCom1": $w("#passedCodeCom1").text,
"passedCode1": $w("#passedCode1").text,
"comPrice1": $w("#comPrice1").value,
"result1": $w("#result1").text,
}
})
.then(() => {
$w('#emailStatus').show();
})
.catch( (err) => {
$w('#emailStatusErr').show();
} );
}
})
}
and set up some hidden text boxes to show if the email sent successfully or not:
The button on the left submits for the current logged in user. “Email NOT sent” is always showing when I click the button to submit the email.
I am presently logged in as a user.
I also tried to see if it would work for non-logged-in users. I added an email address input box and another button on the right connected to the code below but this also does not send any email:
import wixCRM from 'wix-crm';
export function emailButton2_click(event) {
wixCRM.emailContact('SCsix8E', $w("#emailInput").value, {
variables: {
"fkHeading1": $w("#fkHeading1").text,
"comQTY1": $w("#comQTY1").value,
"passedPrice1": $w("#passedPrice1").text,
"passedCodeCom1": $w("#passedCodeCom1").text,
"passedCode1": $w("#passedCode1").text,
"comPrice1": $w("#comPrice1").value,
"result1": $w("#result1").text,
}
})
.then(() => {
$w('#emailStatus').show();
})
.catch( (err) => {
$w('#emailStatusErr').show();
} );
}
Can anyone see what I am doing wrong???