How can I send personalized email to customer

Hi there !
Is it possible to send a personalized email with unique content to each while selecting multiple list of email.
currently I can send if only I select single email, if I select multiple than the same message id passed to each. I am using send grid template for email.
Is there any way around it ?
I will appreciate your help kindly guide !
thank you !


I want to send the email having topic, batch, time and date as per the teacher selected.

<h3 style="background-color:Black">
Hello 👋
<br>
<br>
{{ usersTable.selectedRow.data[i].email }} !
<br>
<br>


You have a scheduled class on {{ usersTable.selectedRow.data[i].Topic }} :
<br>
<br>
<b>Date: {{ usersTable.selectedRow.data[i].Date }} 
<br>
<br>
<b>Time: {{ usersTable.selectedRow.data[i].Time }}
<br>
<br>
<b>Batch: {{ usersTable.selectedRow.data[i].Batch }}
<br>
<br>
*********************************
<br>
Community Medicine Dept.
  <br>
    Govt Medical College,
  <br>
    Majuragate, Surat
  <br>
*********************************
<br>

above code works for single selection only !

Hey drnaresh, You could loop through the array of teachers in a JS query and trigger your SendGrid query with each teacher's unique information using addtionalScope. These two different docs give examples of how to set that up:

https://docs.retool.com/docs/scripting-retool#triggering-a-query-for-each-item-in-an-array

https://docs.retool.com/docs/scripting-retool#triggering-a-query

I hope that helps :grinning_face_with_smiling_eyes:

@everett_smith thank you for the help, what to write in emailTexteditor after creating additional query using additional scope, can you give more details, I am little confused here .
thanks !

Hey @drnaresh, You might need to construct this HTML as a string in your JS query for each email recipient as you iterate over the email recipients in your table. That would allow you to insert the customized values (such as {{ usersTable.data[i].email }}). You could then pass that constructed HTML to your SendGrid query using additionalScope.

Could that work for your use case? Or do you need your users to be able to change the script of the email in the Rich Text Editor?

It might be helpful to see a screenshot of your SendGrid query here as well.

1 Like

Thnak you @everett_smith !
I am posting SendGrid query


sendEmails query

var emails = usersTable.selectedRow.data.map(row => row.email)
emails.forEach(function(email) {
  sendEmail.trigger({
    additionalScope: {
      'additionalScopeEmail': email
    }
  })
})

thanks