Hi been trying to send a triggered email with code to a new contact. But sometimes it sends, sometimes it doesn’t.
The contact keeps getting created. So that step is working. But the error in the preview is shown for sending the email. Sometimes it goes through without error but the email is not sent.
Really frustrating. And not sure what I am doing wrong/right? Code is below.
Any suggestions?
import wixCrm from 'wix-crm';
$w.onReady(function () {
});
export function button1_click(event) {
wixCrm.createContact({
"firstName": $w('#input1').value,
"emails": [$w("#input3").value],
"number": $w("#input2").value
})
.then((contactId) => {
wixCrm.emailContact("Rqx3cXf", contactId, {
"variables": {
"name": $w("#input1").value,
"number": $w("#input2").value
}
})
.then(() => {
console.log("success");// do something after the email was sent
})
.catch((err) => {
console.log("error");// handle the error if the email wasn't sent
});
});
}