Thank you very much! you finally solve my problem. Very useful and smart solution.
Just an optimization: I use this more general sendEmail function in the backend
import wixCRM from ‘wix-crm-backend’ ;
import wixUsers from ‘wix-users-backend’ ;
export function sendEmail(triggerMailID,emails,variables)
{
wixCRM.createContact({
“emails” : emails
})
.then(contactId => {
console.log( “sending mail” );
return wixCRM.emailContact(triggerMailID, contactId, variables)
.then( () => {
// do something after the email was sent
console.log( “mail sent” );
})
. catch ((err) => {
// handle the error if the email wasn’t sent
console.log(error : ${err});
})
})
}