Question:
How can I send an email to a recipient by the click of a button
Product:
Wix Editor
What are you trying to achieve:
I have a form, where visitors can enter the information, including their email address. This is saved in my collection.
I have another page (member area), where it displays all the information, the visitor has entered.
I would like to have a button, that I can click on to send an email to the visitor. The email address is in a text box, connected to CMS and when I click the button, I need the code to fetch the email address and send it to the recipient. I have created a Triggered Email with an email, that I want to send.
What have you already tried:
I have tried this code without any luck. It just doesn’t send the email:
import { triggeredEmails } from ‘wix-crm’;
$w.onReady(function () {
$w(“#button”).onClick(() => {
const recipientEmail = $w("#textbox").text;
console.log("E-mailadresse hentet fra textbox:", recipientEmail);
triggeredEmails.emailMember('emailID', recipientEmail)
.then(() => {
console.log("E-mail send successfully:", recipientEmail);
})
.catch((err) => {
console.error("E-mail send failed:", err);
});
});
});
Additional information: