Send an email with each row of a datatable including it's header

Hello,

I have the following issue, I need to send an email for each row of a datatable (read from an excel).

Assuming that I would have multiple excels with a different number of columns and different column names how should I proceed to send an email that will contain the header and only one row of that datatable.

Thanks in advance!

Hi @darie.leolea
Refer the below thread,It helps you

or

For Each Row (Input: dataTable)
    Assign emailContent = ""

    For Each column In dataTable.Columns
        Assign emailContent = emailContent + column.ColumnName + ": " + row(column).ToString + Environment.NewLine

    Send Outlook Mail Message
        To: recipientEmail
        Subject: "Data Row Details"
        Body: emailContent

Hope it helps!!

Hi @darie.leolea

dt.Rows(0)("ColumnName").ToString

An essential modelling could start like the following:

For each Row in dataTable | currentRow in YourDataTableVar

  • Assign Activity dtOnlyRow = new DataRow(){currentRow}.CopyToDataTable
  • Send email

Hi @darie.leolea

->Let’s say you have an OutputDataTable in which theentire data is stored.
->Take the NewOutputDataTable = OutputDataTable.Clone() (Store’s the headers)
->Take the Add Data Row Activity and consider the DataRow as OutputDataTable.Rows(0) and add that to the NewOutputDataTable
->Use an Create HTML Content activity and pass the NewOutputDataTable variable into it
->Use the output of Create HTML Content activity into send email activity and the mail will be sent with the data table along with header and also contains only one row.
->Don’t forget to check the Is body as HTML in send email activity.

Regards