sendEmailWithRecipient NOT working

I set up the code as explained on here: Velo Tutorial: Sending an Email on Form Submission | Help Center | Wix.com

The “sendEmail” function is working fine.

The “sendEmailWithRecipient” is not working.

Following code in the backend:
import {sendWithService} from ‘backend/sendGrid’;

export function sendEmail(subject, body) {
const key = “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”;
const sender = “robert.fraunhoffer@vatrium.de”;
const recipient = “robert.fraunhoffer@vatrium.de”;
return sendWithService(key, sender, recipient, subject, body);
}

export function sendEmailWithRecipient(subject, body, recipient) {
const key = “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”;
const sender = “robert.fraunhoffer@vatrium.de”;
return sendWithService(key, sender, recipient, subject, body);
}

Following code on th page:
import {sendEmail,sendEmailWithRecipient} from ‘backend/email’;

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

function sendFormData() {
const subject = Ihre Schulungsbestätigung ${$w("#dropdown2").value};
const body = Inhalte folgender Schulung bestätigt und zur Kenntnis genommen: ${$w("#dropdown2").value} \rName: ${$w("#input3").value} \rE-Mail: ${$w("#input4").value};
const recipient = $w(“#input4”).value;

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

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

Can someone please help? Many thanks!!!
Robert

Try this:

 sendEmailWithRecipient(subject, body, recipient)
    .then( () => {
       sendEmail(subject, body)
    });

you need to import sendEmailWithRecipient in your code, at the top of code into your page:
import {sendEmailWithRecipient} from ‘backend/email’;

I think he is already doing that

@ shan: if i switch the code to the one you provide, still only the sendEmail is working. SendEmailWithRecipient still not working.

Do you have any other ideas?
Regards Robert

try this:

function sendFormData() {
 const subject = `Ihre Schulungsbestätigung ${$w("#dropdown2").value}`;
 const body = `Inhalte folgender Schulung bestätigt und zur Kenntnis genommen: ${$w("#dropdown2").value}
    \rName: ${$w("#input3").value}
    \rE-Mail: ${$w("#input4").value}`;
 const recipient = $w("#input4").value;
 
  sendEmailWithRecipient(subject, body, recipient)
   .then( () => { 
    recipientEmail()
   });
}

function recipientEmail() {
 const subject = `Ihre Schulungsbestätigung ${$w("#dropdown2").value}`;
 const body = `Inhalte folgender Schulung bestätigt und zur Kenntnis genommen: ${$w("#dropdown2").value}
    \rName: ${$w("#input3").value}
    \rE-Mail: ${$w("#input4").value}`;
  sendEmail(subject, body);
}