Ok, I got it working, except it is trying to send emails too fast and it keeps failing. What do I do? I have a list in content manager with all the email addresses i want to send the triggered email to
. I made a code that gets the value of each email, then creates a contact and sends an email. here is my code:
export function sendEmail ( tcode , email ) {
wixCRM . createContact ({
“firstName” : email ,
“emails” : [ email ]
})
. then (( contactId ) => {
console . log ( contactId )
wixCRM . triggeredEmails . emailContact ( tcode , contactId , {
“variables” : {
idCode : email
}
})
. then (() => {
console . log ( “Sent!” )
// do something after the email was sent
})
. catch (( err ) => {
console . log ( “err” )
// handle the error if the email wasn’t sent
});
});
// This function was added from the Properties & Events panel. To learn more, visit Velo: Working with the Properties & Events Panel | Help Center | Wix.com
// Add your code for this event here:
}
/**
- Adds an event handler that runs when the element is clicked.
Read more - @param {$w.MouseEvent} event
*/
/**
- Adds an event handler that runs when the element is clicked.
Read more - @param {$w.MouseEvent} event
*/
export async function yesButton_click ( event ) {
await wixData . query ( “Codes” )
. find ()
. then ( ( results ) => {
if ( results . items . length > 0 ) {
for ( let i = 0 ; i < results . items . length ; i ++) {
console . log ( "i = " + i )
let curItem = results . items [ i ]
console . log ( "email = " + curItem . value )
sendEmail ( “Spp8KfP” , curItem . value )
}
//see item below
} else {
// handle case where no matching items found
}
} )
. catch ( ( err ) => {
let errorMsg = err ;
} );
// This function was added from the Properties & Events panel. To learn more, visit Velo: Working with the Properties & Events Panel | Help Center | Wix.com
// Add your code for this event here:
}
