How to create Mail Body from Data Table with the help of LINQ?

Hi Experts,

I want to create mail body from Data Table and the design should be exactly same shown in screenshot.
image

Please refer attached excel file.
createMailBody.xlsx (9.0 KB)

I am looking for your help.
Thanks.

Note: Please don’t suggest looping option

Hi,

Have you tried this one

Yeah i have tried it but i also want some colour specific columns i stuck there.
How we can put the condition to colour some of the columns and rows, the way i have shown in screenshot?

I can see row & column headers are coloured in above Screenshot.
So, use <th> tag for both of those headers and add CSS for <th> html tags

1 Like

How to write condition as first column do not have background color but other have?
Similar way first cell of each row have color but other don’t.

Can you please share Linq ?

I don’t have ready linq expression with me.

But you can try below steps.

  1. Take clone of existing datatable - ColorDT.
  2. Use linq and get x,y index if each cell. Call VB method to get background colour from excel sheet for that XY value. Update corresponding cell in ColorDT with colour code
  3. Now you have 2 DTs. One with actual values and other with corresponding colour value in cells
  4. Put some logic and update HTML cell style property