How to create dynamic HTML table rows and pass data dynamically?

hi,

I am working on usecase where I need to send email to teachers, with table data. I have specific template in .docx. in that there are few paragraphas then there is table, with heading and it can have 1 row, 2 or 3 or may be till 7 8 . it is dynamic.

In attched excel, 1st column is school ID, I have added data to Orch , each row is transaction.. So as per teachers ID we need to send mail. I have developed the scenario where I am able to send mail as per each row, I was not aware 1 teacher can have multiple subj. that there should be 1 each per teacher. table row can increase.

please suggest solution, how can I use 1 row as transaction and how i can send 1 email per teacher code ?

I have the data in xlsx as well, can I take trasanction from queue and then filter excel? but then what if same teacher code appers in next trasanction then it will be double mail.

need help

  1. on logic
  2. how to make dynamic table and pass variable from excel rows or transaction item?
  3. How to add 1 extra blank column in table in body of email
  4. how to send email using SMTP, can I pass this to smtp as that is only allowed

Body of mail,

Hi teacher,
please fine feedback and add your comments

SchoolBranch TeacherID Subject Feedback Comments YourView
100 T1 M1 RERWE FVCXV
100 T1 M2 RRW VBCB
100 T1 M11 DFDFG GBGBGBFGHNF

thanks
ff
fsfsf


Input.xlsx (9.2 KB)

Hi @Nidhi_Gupta1

  1. First Read Excel using Read Range Workbook and store in DT_Input

  2. Then Group data by TeacherID , using LINQ –
    List_Teachers = DT_Input.DefaultView.ToTable(True,“TeacherID”)

  3. Loop now through each TeacherID, Inside loop use below code , this will make data for TeacherID
    currentTeacher = item(“TeacherID”).ToString
    DT_Teacher = DT_Input.AsEnumerable().
    Where(Function(x) x(“TeacherID”).ToString = currentTeacher).
    CopyToDataTable()

  4. Build Dynamic HTML Table for Email :

    htmlTable = "

    "

    For Each row In DT_Teacher.Rows
    htmlTable &= “

    ” &
    “” &
    “” &
    “” &
    “” &
    “” ’ ← Extra blank column as requested
    Next

    htmlTable &= “

    SchoolBranchTeacherIDSubjectFeedbackCommentsYourView
    ” & row(“SchoolBranch”) & “” & row(“TeacherID”) & “” & row(“Subject”) & “” & row(“Feedback”) & “” & row(“Comments”) & “

    1. Now our data is ready in html, then send an email.
    2. For every transaction, bot will do thses steps and complete it.

      NewActivity.xaml (19.7 KB)

    I have attached the xaml for your reference.

1 Like

Hi @MohammedShabbir

Thanks for reply !
I will implement and revert to you for sure.

1 more doubt , what if 2nd occurrence appears as a transaction
How to check that ??

Or else it might send 3 times mail to TO with 3 rows . It should go only once ..
I an stuck in framework logic

As 1 row as a 1 transaction I added ,
TIA!

Mails will go only once, that’s the reason we are creating in teacher list in step 2. This will give only unique teacher list.
Using this list we will extract data table from main datatable.
Try step by step.
NewActivity.xaml (19.7 KB)

@Nidhi_Gupta1

Instead of adding each row to queue as transaction add the teacher ID as the transaction item

when you process the item filter using ID and you would get all rows related to teacher

now if you use create HTML content activity you can directly pass the datatable and it would give the required html table that can be used in the email activity

Hope this helps

cheers

1 Like