Custom Form - handling attachments

Many thanks for taking the time to respond.

Sorry if you thought my post was not helpful !! I was trying to be economical with what I wrote ! So in answer…the live site is this one:

The form I am trying to use is this one (none dynamic):

https://www.stayontrackvetphysiotherapy.co.uk/new-referral-form

I have a Collection in my site directly generated by that form…most fields are freeform text / a couple of Address fields / a date field…some dropdown choices…it’s not a huge form

I am not sure what a REPEATER is in this context so I would assume I do not use one !

There are 3 code elements: 2 in the BackEnd (email.jsw and sendGrid.js) and Page Code (as described in the article I referenced)

BackEnd code elements (some stuff anonymised):

//email.jsw

import {sendWithService} from ‘backend/sendGrid’;

export function sendEmail(subject, body) {
const key = “#############”;
const sender = "sender email ";
const recipient = “my email”;
return sendWithService(key, sender, recipient, subject, body);
}

export function sendEmailWithRecipient(subject, body, recipient) {
const key = “SSG.WMIyqFcATdqhNAOee_c7RA.fICFX4Bh7xpkAHrisdNJ5gUHtz1jDfE5iNSen7shjyo”;
const sender = “sender email”;
return sendWithService(key, sender, recipient, subject, body);
}

//sendGrid.js

import {fetch} from ‘wix-fetch’;

export function sendWithService(key, sender, recipient, subject, body) {
const url = “https://api.sendgrid.com/api/mail.send.json”;

const headers = {
“Authorization”: "Bearer " + key,
“Content-Type”: “application/x-www-form-urlencoded”
};

const data = from=${sender}&to=${recipient}&subject=${subject}&text=${body};

const request = {
“method”: “post”,
“headers”: headers,
“body”: data
};

return fetch(url, request)
.then(response => response.json());
}

PageCode: (this version ignores the File Upload content but I tried to use the syntax from my earlier post and it failed)

import {sendEmail, sendEmailWithRecipient} from ‘backend/email’;

$w.onReady(function () {
$w(“#dataset1”).onAfterSave(sendFormData);
});

function sendFormData() {
const subject = New Vet Referral Form from ${$w("#input1").value};
const body = New Vet Referral from ${$w("#input1").value} \rOwners Name: ${$w("#input1").value} \rOwners Email: ${$w("#input2").value} \rOwners Contact Number: ${$w("#input3").value} \rOwners Address and Post Code: ${$w("#addressInput3").streetAddress} \rAnimals Name: ${$w("#input4").value} \rAnimal Species: ${$w("#dropdown1").value} \rAnimal Breed: ${$w("#input5").value} \rReferring Vet: ${$w("#input6").value} \rReferring Vet Practice: ${$w("#input7").value} \rPractice Address and Postcode: ${$w("#addressInput2").value} \rVet Email: ${$w("#input8").value} \rVet Phone: ${$w("#input9").value} \rBrief Description of the Problem: ${$w("#input10").value} \rPreference for making this appointment: ${$w("#dropdown3").value};
const recipient = $w(“#input8”).value;

sendEmailWithRecipient(subject, body, recipient)
.then(response => console.log(response));

sendEmail(subject, body)
.then(response => console.log(response));
}