I had a datatable in an Excel File(see attached file)
I want to send an email par id (in column1 )for the mails 'in column1).
for example: in the Excel file attached i will send 3 mails:
for IID 1: one mail with a body containing: addr1, addr3, addr7, Red, Grey and harmony
for IID 2: one mail whit a body containing : addr2, addr6, Blue, Black
for IID 3: one mail whit a body containing : addr4, addr5, yellow, white
On the begin also a Non-LINQ approach is presented
row in dtData.DefaultView.ToTable(True, {“IID”})
so the data will be grouped by IID column
Within the group member processing the email body can be constructed e.g. by concatenation of the group member column values or taking the datatable with only the group related rows
File1 n°[ N° d’enregistrement][ BGE Paye][ Mois]of the agent
File2 n°[ N° d’enregistrement][ BGE Paye][ Mois]of the agent
-…
Regards,
The robot"
So the robot will send 2 mails , in each mail it fill the body with correspondant information, the word in are the column values read from the Exel i had attached sample.xlsx (25.9 KB)
I had used the formula: (From DR In DT_Input.AsEnumerable Group DR By Col0=DR("Column28").toString.Trim Into grp=Group Let Col1 = String.Join(",", grp.Select(Function (col1Field) col1Field("Column1").toString).toArray) Let Col2 = String.Join(",", grp.Select(Function (col2Field) col2Field("Column0").toString).toArray) Let Col3 = String.Join(",", grp.Select(Function (col2Field) col2Field("Column6").toString).toArray) Let Col4 = String.Join(",", grp.Select(Function (col2Field) col2Field("Column2").toString).toArray ) Let Col5 = String.Join(",", grp.Select(Function (col2Field) col2Field("Column3").toString).toArray ) Let Col_Array = New Object(){Col0, Col1, Col2,Col3,Col4,Col5} Select DT_Output.Rows.Add(Col_Array)).CopyToDataTable
Thnak you for the advice, i tried the html, i got :
Append Line: The index was out of bounds. It must not be negative and must be less than the size of the collection.
Parameter name: index