Concatenate Row Items into a String

I have created a data table using the Read CSV Activity and have stored it in a variable called DT. I then used a For Each Row Activity with a Get Row Item Activity to retreive all the email addresses from the data table listed in a specific column. I have stored the row items found in the For Each Activity in a variable called rowItem. I would like to convert each Row Item into a concatenated string separated by a semi-colon.

I tried to use the Assign Activity to make a new variable called email = string.Join("; ",rowItem). When I test this using a Message Box Activity, it creates a separate message box with each email address with a semi-colon at the end.

What I am trying to do is create a string where all emails addresses found in the CSV file appear in one line separated by a semi-colon so that this variable can be used in the β€œTo” field of an e-mail message. Currently, the email is only being sent to the first email address found. The others are ignored.

Can someone help me figure out what I need to assign the email variable to so that I can use all of the row items found in the CSV file in an e-mail?

I think you will have to create email in a global scope and the message box has to be put outside the foreach if you want to see the final value.

Thank you. This helped me solve my issue.

Actually, I did not need to Concatenate the found Row Items. I needed to put the Send Outlook Mail Activity INSIDE the For Each container. This allows the Bot to send the e-mails individually to each found item.

Thank you for your quick response.

1 Like

As an update to what I was trying to do originally, here is the code that needs to go into the Assign Activity.

String.Concat(rowItem, "; ", email)

3 Likes

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