Hi Wix Community,
I am having a little trouble with my triggering email. For some reason I am trying to use one of my own emails to test it. I have set up everything through Code and adding the Trigger Name and also set up the Automation email that is sent to me. It is a very basic form and yet it isn't sending an email out to the one I input in my custom form.
Would it by chance be because of having the Contact email in the CRM already that it will not read it as a new contact? Mind you have both the new contact code in there as well as the wixUser code.
Please help.
Note: My database is connected and everything is working fine. It is just not sending the email out to the recipient who imputed the information. Also my automation email works like a charm and it displays the text values that were imputed on the form when filled out.
Code is below:
import wixCRM from 'wix-crm';
import wixUsers from 'wix-users';
$w.onReady(function () {
//TODO: write your page related code here...
}); let userId = wixUsers.currentUser.id; let newname = $w('#input1').value let newemail = $w("#input2").value let newmessage = $w("#textBox1").value export function signUpButton_click() { wixCRM.createContact({ "firstName": newname, "lastName": newname, "emails": [newemail] }) .then((contactId) => { wixCRM.emailContact("formtest", contactId, { "variables": { "subscriberName": newname, "subscriberMessage": newmessage } }) .then(() => { // do something after the email was sent }) .catch((err) => { // handle the error if the email wasn't sent $w('#text157').text = "error sending email:" + err; $w('#text157').show(); }); }); wixUsers.emailUser("formtest", userId, { "variables": { "subscriberName": newname, "subscriberMessage": newmessage } } ) .then( () => { console.log("Triggered email sent"); $w('#text157').text = "Email Sent!"; $w('#text157').show(); } ) .catch( (err) => { console.log(err); $w('#text157').text = "error sending email:" + err; $w('#text157').show(); } ); }
Do you use the createContact function to a contact which is already existed in your CRM contacts?