I set up the code as explained on here: https://support.wix.com/en/article/corvid-tutorial-sending-an-email-on-form-submission
The "sendEmail" function is working fine.
The "sendEmailWithRecipient" is not working.
Following code in the backend:
import {sendWithService} from 'backend/sendGrid'; export function sendEmail(subject, body) { const key = "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"; const sender = "robert.fraunhoffer@vatrium.de"; const recipient = "robert.fraunhoffer@vatrium.de"; return sendWithService(key, sender, recipient, subject, body); } export function sendEmailWithRecipient(subject, body, recipient) { const key = "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"; const sender = "robert.fraunhoffer@vatrium.de"; return sendWithService(key, sender, recipient, subject, body); }
Following code on th page:
import {sendEmail,sendEmailWithRecipient} from 'backend/email'; $w.onReady(function () { $w("#dataset1").onAfterSave(sendFormData); }); function sendFormData() { const subject = `Ihre Schulungsbestätigung ${$w("#dropdown2").value}`; const body = `Inhalte folgender Schulung bestätigt und zur Kenntnis genommen: ${$w("#dropdown2").value} \rName: ${$w("#input3").value} \rE-Mail: ${$w("#input4").value}`; const recipient = $w("#input4").value; sendEmailWithRecipient(subject, body, recipient) .then(response => console.log(response)); sendEmail(subject, body) .then(response => console.log(response)); }
Can someone please help? Many thanks!!!
Robert
@ shan: if i switch the code to the one you provide, still only the sendEmail is working. SendEmailWithRecipient still not working.
Do you have any other ideas?
Regards Robert