Hi there,
How can I modify the code so I will have 2 separate subject lines? - one for the site owner - “Someone filled-in the form - Mr.X Y Z” (this one is already set ! ) and the other for the visitor who filled-in the form + a text line above the inputs, within the email saying: “Thank you for contacting us. Here are the details you filled-in:”
Thanks in advance as always,
Naama.
Hi,
if you are using code from our article (Velo Tutorial: Sending an Email on Form Submission | Help Center | Wix.com), you could use sendEmailWithRecipient function to send e-mail. Then in your after save event handler you would call that function twice:
function sendFormData() {
const ownerSubject = `New Submission from ${$w("#nameInput").value}`;
const clientSubject = 'Thank you for contacting us!';
const ownerBody = `Name: ${$w("#nameInput").value}
\rEmail: ${$w("#emailInput").value}
\rSport: ${$w("#sportDropdown").value}
\rComments: ${$w("#commentsInput").value}`;
const clientBody = `Thank you for contacting us. Here are the details you filled-in: \r\n ${ownerBody}`
const ownerEmail = 'your@mail.com'
const clientEmail = $w("#emailInput").value;
sendEmailWithRecipient(ownerSubject, body, ownerEmail)
sendEmailWithRecipient(clientSubject, clientBody, clientEmail)
}
So, here I am constructing different subjects and e-mail contents (bodies) for different recipients and sending both of the e-mails.
I hope this helps! Don’t hesitate to continue the thread if you have more questions. Good luck Wix Coding!
Awesome! Thank you very much.
I’ll try it soon and keep this thread updated
Yay, I finally took the time to do this and it worked !
Thanks a lot!