Send email to dataset field

hi everyone I have a dataset that has a page with a repeater. I would like to add a button to the repeater to send an email to a field that is in the dataset. can anybody point me in the right direction as I am totally lost :frowning:

thanks

Hello. To add a button to your repeater you can drag a button element over the repeater in the UI and it will indicate to attach it to the repeater.

As for setting up the logic, I would search through the forum first for others who have added buttons to repeaters as that is a common subject.

You can also search for send email on button click for other forum posts that may be similar to your use case.

Is that enough to get you started on where to find the information?

You should read this thoroughly first https://support.wix.com/en/article/velo-tutorial-sending-a-triggered-email-to-members
Then the first thing you should know is that the mails can only be sent if the person who clicks the button is logged in to the site.
I wish you had given more information. You could take a screenshot of the repeaters with the codes you wrote. Anyway.

You can do something like this;

import { triggeredEmails } from 'wix-crm';
import { currentMember } from 'wix-members';

$w.onReady(function() {
   $w("#myRepeater").onItemReady( ($item, itemData, index) => {
     $item('#myButton').onClick(()=>{
       let myField = itemData.myField;     
       sendMail(myField)
     })
   });
});

async function sendMail(myField){
  const member = await currentMember.getMember()
       if (member) {
           const userId = member._id;
           triggeredEmails.emailMember("customMail", userId, {
               variables: {
                   "fieldVariable": myField
               }
           })
       }
}

If the message is going to other mails not current member’s mail, you should use sendgrid.