Passing List in Create HTML Content Activity

Hello Automation Family,

I have a query, hope you guys will help me out. I am doing an Outlook email automation and using Send Outlook Mail Message, in this activity I am passing the variable generated from Create HTML Content activity in email body. I have 2 List (one for Name and one for NIC number and both list have 5 items only) that I have to pass in Create HTML Content as argument… I just wanted to know what will be the syntax to pass a list in Create HTML Content, also I am not getting the desired output on Email from following syntax below.

Output I am getting on Email with this syntax

Need quick response Thanks.

Hii @Zen_Ahmed ,
Can you just give a try by mentioning the index while mapping the variables? like mentioned below.

image

Regards,

1 Like

I have to pass 2 lists in single email both having 5 5 values. with this way I have to create 10 variable. Is there any other way?

@Zen_Ahmed

Another method is as below…

You can first create a datatable out of the lists and then pass the table directly

  1. Use build datatable and create two string columns
  2. Now use assign dt = names.Zip(ages).Select(function(x) dt.Rows.Add(x.Item1,x.Item2)).CopyToDataTable
  3. Now use the table directly in create html content activity

This is how it looks

cheers

1 Like

Great, Thanks

1 Like

Need some understanding on Linq query. Can you please explain?

@Zen_Ahmed

names.Zip(ages).Select(function(x) dt.Rows.Add(x.Item1,x.Item2)).CopyToDataTable

Zip(names.Zip(ages)) will create a tuple from the given lists…like List1{1,2,3} and list2(a,b,c} now zip will create an enumerable of tuples {(1,a),(2,b),(3,c)}

Then From this enumerable I am selecting(.Select(function(x) dt.Rows.Add(x.Item1,x.Item2)))…or trying to get each tuple and then adding the values as datarow to the datatable dt1(dt.Rows.Add(x.Item1,x.Item2))

Select will get each item…and for each item a datarow is created…now using copytoDatatable I am adding all the rows generated to a datatable

Hope this helps

cheers

Appreciated… but unfortunately getting error, screenshots attached :frowning:

image

@Zen_Ahmed

Did you add build datatable before this…as depicted in above images…and add teo columns of string type?

And assign dt in the output variable of the build datatable…

The error says that you did not do it…we get this error when one of the variable used is null

Please check the same

Cheers

Hi,

Can you try the following sample?

This works even if count of both list is different.

"CNIC"+chr(9)+"NAEM"+vbcrlf+String.Join(vbcrlf,ListB.Select(Function(s,i) if(i<ListA.Count,ListA(i),"")+chr(9)+s))

Sample20230322-6L.zip (3.8 KB)

Regards,

It worked!! TYSM

1 Like

Thanks. Working as well

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.