Distinct Values from excel and send mail

How to make distinct district? (employee district column in excel)
How to send mail to employees from same district ?

@ajaynnair2

follow the steps

  1. Read the data into datatble dt
  2. Use a for loop and give in argument as dt.AsEnumerable.GroupBy(function(x) x("Column1").ToString).ToArray.ToDictionary(Function(g) g.Key, Function(g) g.CopyToDataTable).Values and select type argument as Datatable
  3. Now inside the loop for each iteration you will get each group as Datatable which is currentitem…Can use send email inside to send the grouped table

Use create html content activity to convert datatable to html table if needed

Hope this helps

cheers

1 Like

Hi @ajaynnair2 ,

Maybe could you give some more details as to how you would want the Output ? Do you want to send mail to all the emails of One District at once (One Email )

If so, You could Check the below Expression :

OutputDT = (From r in DT Group by k=r("Column2").ToString Into grp=Group 
Let emails = String.Join(";",grp.Select(Function(x)x("Column1").ToString).ToArray) 
Select OutputDT.Rows.Add(new Object(){emails,k})).CopyToDatatable

From the Debug with Sample Data :
image

Let us know what is the exact requirements if the suggestions provided did not satisfy the requirement.

if wayanad comes i want to send email to all employees from wayanad dist

@ajaynnair2

If thats the requirememt then directly use a filter datatable and filter datatable with the required input city…

Then in the filtered table you will have only that city details…
Can use for each row in datatable and send email to each person

Cheers

1 Like

@ajaynnair2 ,

Check the resultant Datatable from the query, It does concatenate all the emails of Wayanad together.

Meaning when looping through that Datatable, You will have unique District names, and the emails are all concatenated so that you can directly use the emails data in the To Section of Send Mail activities.

1 Like