I checked this forum
https://www.wix.com/corvid/forum/community-discussion/include-images-documents-in-form-submission-email
It’s works.
But when only 1 image sends, it does not work.
Please help me.
import {sendEmail} from 'backend/email';
$w.onReady(function () {
$w("#dataset1").onAfterSave(sendFormData);
});
// wix:document://v1 -> docs.wixstatic.com/ugd
function sendFormData() {
try{
const item = $w("#dataset1").getCurrentItem();
const wiximageurl = "https://static.wixstatic.com/media/";
let imagelocal = "";
imagelocal = item.image.replace('image://v1/', '');
imagelocal = imagelocal.substr(imagelocal.lastIndexOf('/')+1);
const imageUrl = wiximageurl + imagelocal;
let whoimagelocal = "";
whoimagelocal = item.whoimage.replace('image://v1/', '');
whoimagelocal = whoimagelocal.substr(whoimagelocal.lastIndexOf('/')+1);
const whoimageUrl = wiximageurl + whoimagelocal;
const subject = `From website: ${$w("#input1").value}`;
const body = `plan: ${$w("#dropdown1").value}
\name: ${$w("#input1").value}
\mail: ${$w("#input2").value}
\birthday: ${$w("#datePicker1").value}
\image: ${imageUrl}
\onother: ${$w("#checkbox1").value}
\name2: ${$w("#input3").value}
\relationship: ${$w("#input4").value}
\birthday2: ${$w("#datePicker2").value}
\image2: ${whoimageUrl}
\comment: ${$w("#richTextBox1").value}
`;
sendEmail(subject, body)
.then(response => console.log(response));
}catch(e){
const subject = `From website: ${$w("#input1").value}`;
const body = `plan: ${$w("#dropdown1").value}
\name: ${$w("#input1").value}
\mail: ${$w("#input2").value}
\birthday: ${$w("#datePicker1").value}
\onother: ${$w("#checkbox1").value}
\name2: ${$w("#input3").value}
\relationship: ${$w("#input4").value}
\birthday2: ${$w("#datePicker2").value}
\comment: ${$w("#richTextBox1").value}
`;
sendEmail(subject, body)
.then(response => console.log(response));
}
}