Sending an email using information from an Excel file


New RPA user here! I’m trying to automate an email that I send out to users at the beginning of a rollout phase. Because the users are new each phase, the distribution list changes each time. The email addresses of the users are located in an Excel file that I can use while creating the email automation. If I use the “for each row,” fuction, this simply creates a new email for each row. Rather, I want the automation to pull the addresses from the specified column in Excel and send 1 email to them as a group. Is there an easy way to do this?

Yes, its fairly simple.

You can read the spreadsheet then concatenate all of the rows (email addresses) in to a single string.

You can use datatable extensions to retrieve all the values from a single column and then another function to put them into a string

datatable.AsEnumerable().[Select](Function(x) x("COLUMN").ToString()).Aggregate(Function(a, b) String.Concat(a, ";" & b))

Replace Datatable and COLUMN with your values.

It needs to be seperated by ;

That string can then be entered into the To field of send email.

If you receive an error for AsEnumerable follow this link:

1 Like

Thank you! That is a good idea. For the datatable function, though, would that also work with StudioX, or just Studio?

Nevermind! I played around in Excel, and I found that the “=TEXTJOIN” formula will combine the text from multiple cells into 1 cell (and you can specify a deliniator!). I added the formula as a “write cell” activity, and used this to populate the “To” field in the send email activity. Thank you again for the suggestion.

1 Like