Sending an email with recipient from an existing collection

Hi guys,
I’d need some help. I’m not very good at coding and I got stuck in a fairly important issue of my future website.

Thanks to this article I learned how to send emails on form submission, but now I’d need to change a recipient of my emails.

Let’s say that one of the input fields in my form is called “City”. A visitor of my page enters into this field “London”.

Now, I already have an existing collection of vendors (collection name: “Vendors”). Every vendor has, among other, filled in information in a column “Town” and “Email”. Lets say that 3 of my vendors have in a pertaining cell “Town” filled in the value “London”.

What I would like to achieve is, that on a form submission, the value from input field “City” is matched (vlookuped?) in my “Vendors” collection in column “Town” and value(s) from column “Email” is used as a recipient email address(es). (i.e. in given “London” example, emails to 3 vendors should be sent on the form submission.)

I tried to use amended code from this forum post , but it didn’t work for me and I got stuck
Could you please advise?
Thanks a lot!

this is what I have so far:

import {sendEmail, sendEmailWithRecipient} from 'backend/email';

$w.onReady(function () {
  $w("#dataset1").onAfterSave(sendFormData);
  //dataset1 CONNECTS TO A COLLECTION THAT IS CREATED AS USER INPUT,
 // AFTER THEY FILL IN THE FORM - IT IS NOT CONNECTED TO "VENDORS" COLLECTION
});

function sendFormData() {
  const subject = `Submission from ${$w("#input5").value}`;
  const body = `Name: ${$w("#input5").value}
    \rEmail: ${$w("#input6").value}
    \rParameter1: ${$w("#input2").value}
    \rDate: ${$w("#datePicker1").value}`;
    // inputs ARE INPUTS FROM THE FORM THAT IS BEING FILLED IN
    
    const recipient = 
    WHAT PIECE OF CODE SHOULD I PUT HERE? HOW SHOULD THE RECIPIENT BE DEFINED?
    ;
 
  sendEmail(subject, body)
    .then(response => console.log(response))
    .catch(error => console.log('error', error));
  sendEmailWithRecipient(subject, body, recipient)
    .then(response => console.log(response))
    .catch(error => console.log('error', error));
}

(note: sendEmail function, i.e. sending email to myself, works; backend .js and .jsw file seems to be working properly)