How to append new string into items of a List variable

Hello guys! I am currently working on a robot that helps me to conduct research and reply to the users through emails whenever there are unread email requests in the inbox. Now I am stuck at a point that I am trying to append the item of List variable A into List variable B but I am not sure how can I do that.

Each item in List variable A will be in the format like this:
AAA
BBB
CCC
DDD

And each item in List variable B will be an email address, and I want to append each item in List variable B into List variable A with an example like this:
List variable B(0) into List variable A(0)

AAA
BBB
CCC
DDD
example@gmail.com

May I know how can I do this? Thank you very much for your help!

@Komom

List1.concat(list2) this would merge both lists

Cheers

1 Like

Hey @Komom

  • Use an Assign activity to define your ListA and ListB if not already.
  • Use a For Each loop with index (For Each item in ListB with index i)
  • Inside the loop, do:
    ListA(i).Add(item)
    cheers

Hi @Komom
Please find the below workflow,

-You want to different o/p let me know.

If you found helpful, feel free to tick as a solution.
Happy Automation

@Komom

@prashant1603765 Thx for your solution! May I know how can I get that “ItemIndex”? The system error shows that it is not declared. Isn’t it a function in UiPath Studio?

@Anil_G I have tried your solution, and errors occur. May I know which part I did wrong?

@Komom

as per error either EmailAccount is not a list or in assign the left variable is not a list

if emailaccount is not a list then just enclose between flower brackets

cheers

Hi @Komom

Can you try this

List1.Concat(List2).ToList()

Regards,

Thankyou so much for your help!

1 Like

@Komom
Under for each properties section,

Index

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