You will need something into this direction…
import {sendEmail, sendEmailWithRecipient} from 'backend/email';
import {local} from 'wix-storage';
let dbField = [], fieldValue = [];
$w.onReady(function () {let data = [];
let memItems = local.getItem("memory"); console.log("MEMORY: ", savedData);
//---MEMORY-CONTROLLER.....
let toBeMemorized = ["opdrachtTitle", "eMail"]; //<--- put in here, which data to be memorized!
//----------------------------------------------------------------------
const subject = `Nieuwe opdracht geplaatst door ${$w("#input33").value}`;
//-----------------------------------------------------------------------
const recipient = $w("#input34").value;
//-----------------------------------------------------------------------
dbField[0] = "opdrachtTitle"; fieldValue[0] = $w("#input27").value;
dbField[1] = "functieTitle"; fieldValue[1] = $w("#input28").value;
dbField[2] = "omschrijving"; fieldValue[2] = $w("#textBox3").value;
dbField[3] = "eMail"; fieldValue[3] = $w("#input34").value;
//-----------------------------------------------------------------------
const body = `Samenvatting van aangeboden opdracht via Talent Trade
\rOpdracht titel:${dbField[0]}
\rFunctie titel:${dbField[1]}
\rOmschrijving:${dbField[2]}
\rE-mail:${dbField[3]}
Voor wijzigingen of annuleren (24u van tevoren kosteloos wanneer de opdracht al is geaccepteerd) stuur je een reply op deze mail`;
//-----------------------------------------------------------------------
for (let a = 0; a < dbField.length; a++) {
//data[dbField[a]] = fieldValue[a];
for (let b = 0; b < toBeMemorized.length; b++) {
//---MEMORY-FUNCTION for some fields...
if (dbField[a] === toBeMemorized[b]) {
data.push({[dbField[a]]: fieldValue[0]})
}
if(a===dbField.length-1) {
local.setItem("memory", JSON.stringify(data));
}
}
}
//-----------------------------------------------------------------------
$w("#dataset1").onAfterSave(()=>{sendFormData(subject, body, recipient)});
//-----------------------------------------------------------------------
});
function sendFormData(subject, body, recipient) {
sendEmailWithRecipient(subject, body, recipient).then(response => console.log(response));
sendEmail(subject, body).then(response => console.log(response));
}
You will have to expand and optimize the shown code eventually. Give it a try.