Consolidating Information for Companies with Varied Worker Links

I need to send emails using information stored in a datatable. Within the Excel file, distinct columns represent the company, the respective worker, the company’s email, and a link associated with each worker.

Hence, the datatable contains columns for: Company, Worker, Email, and Link.

My objective is to systematically process this data table, sending an email to each company with the link relevant to the respective worker. So far, this process seems straightforward. However, a complication arises from the repetition of companies within the table; although they share the same email address, each occurrence is linked to a different worker and a unique link.
EXAMPLE:

dt_excel:
COMPANY WORKER EMAIL LINK
UiPath SL Alex info@uipath.com www.uipath.com
Facebook SL Kyle hello@facebook.com www.facebook.com
UiPath SL Yugo info@uipath.com www.forum.uipath.com
etc…

Therefore, my aim is to consolidate the information for each company within a single email, encompassing details for all associated workers.

How can I efficiently aggregate the information for each company to compose a collective message? Furthermore, once achieved, how do I proceed to iterate through the datatable and replicate this process for subsequent companies?

Hi Carla,

Please check the attached project and let me know if it works for you.
Demo.zip (4.1 KB)

Cheers!

Hi!

Thank you so much for your work!!

But the task at hand involves sending emails based on information stored in a datatable, where each row represents a worker associated with a company, along with their email and a unique link. The goal is to consolidate this information for each company and send a collective email to each, containing details for all associated workers.

Your project only did for a single worker but if you see the updates I make in the data table you are gonna see that there are more than one worker for a same company.

Demo.zip (4.1 KB)

Hi Carla,
The changes you mention made to the attached project are not reflected. Update it and share it.

If I understand the problem correctly, you could group the datatable by Company column. Then iterate through the groups - each group contain employees for a certain company.

@Carla_Munoz

There are many ways to achieve…Would give you one which is straight…

  1. Use a for loop with dt.AsEnumerable.GroupBy(function(x) x("Email").ToString).ToDictionary(function(x) x.Key,function(x) x.CopyToDataTable)
  2. Inside loop currentitem.Value will give the datatable with all the employees of one compny…
  3. Currentitem.key will give you the email id it is grouped on…

So inside loop just use send email where already you have email id and all data of that compny grouped into one datatable

Hope this helps

Cheers