Grouping/Filtering based on email receiver and sent to each receiver only the respective data

Dear all,
I am struggling in creating a robot which sends emails with information based on the receiver email address in a Excel table.
Each receiver needs to get only one email with his/her information.

Thank you very much in advance!

Information 1 Information 2 Receiver
1992 ABC Receiver-A@email.com
4738 RSP Receiver-B@email.com
3948 SJK Receiver-A@email.com
1124 TEW Receiver-C@email.com
6593 UIE Receiver-B@email.com
9348 MOE Receiver-B@email.com
2317 PER Receiver-C@email.com

image


image


image

@aaydin
you can do a group by and split the groups into tables

assign activity
leftside: TableList (DataType: List(Of DataTable)
Right side:

(From d in YourDataTableVar.AsEnumerable
Group d by k=d(“Receiver”).toString.Trim into grp=Group
Select grp.CopyToDataTable).toList

in a second step us a for each (TypeArgument: DataTable) and iterate over the different group datatables e.g. for sending the different emails

Visuals:
grafik

Acces the group key (in your case the email id) with grp(0)(YourKeyColNameOrIndex).toString:
grafik

find starter help here:
SplitToTableList_1Col.xaml (7.2 KB)

2 Likes

First read the excel file and store in dt1

Then use assign activitiy as

dt2= dt1.DefaultView.ToTable(“Receiver”,True)

This will contains dt2 with only unique reciever names.

Us for each row to loop through each recover value in DT2

Inside it do the following:

Use filter datatable activity to filter Accordingly

Input Datatable: dt1

Output Datatable: dt3

Filter condition

Receiver= row(“Receiver”).ToString

Now the output of filter datatable activity is dt3.

Now after this use for each row to loop through dt3

Since u need to.embeded the each row data in body of email.

You can use HTML.part and embedded the required values.

And after doing that use send mail activitiy to send the mail ( after exiting from for each row of dt3)

Hope the above idea helps you

Regards

Nived N :robot:

Happy Automation :relaxed::relaxed::relaxed::relaxed:

1 Like

Hi Nived,
thank you very much.

How can I embeded the table into the emails?
Do I need to create a data table and add the rows in this table?

Hi @aaydin

U can check this

Regards

Nived N :robot:

Happy Automation :relaxed::relaxed:

Do I need to put the second “for each row”-loop into the first one?

Yes @aaydin