Send outlook email using unique values

Hey guys! I’m simply trying to create a workflow that would send out a bunch of e-mail reminders to managers about one of their people not yet completing a certain survey. I’ve figured out how to do it on a line by line basis, but I’m wondering how can I group together those employees that are under the same manager in order to send one e-mail instead of multiple e-mails.

Below is a sample of the data I’m working with - so my goal is to filter based on whether or not it has been completed which I’ve already figured out. Then my struggle now is how do I send out only ONE e-mail to John sharing with him that employee 3 and 4 haven’t done their survey yet. All in all the output of below data set should be 2 emails via outlook (to Bob and John). Thank you so much!

Hi,

Can you try the following sample?

dtResult = dt.AsEnumerable.Where(Function(r) String.IsNullOrEmpty(r(“Date Completed”).ToString)).GroupBy(Function(r) Tuple.Create(r(“Manager Id”).ToString,r(“Manager Name”).ToString,r(“Manager Email”).ToString)).Select(Function(g) dtResult.Clone.LoadDataRow({g.Key.Item1,g.Key.Item2,g.key.Item3,String.Join(“,”,g.Select(Function(r2) r2(“Employee Email”).ToString))},False)).CopyToDataTable

Sample20220208-1.zip (7.9 KB)

Regards,

Hi Yoichi, thanks a lot for your inputs. I got it to work however, I’d still like to include the rest of the data on the sheet but seems that this approach only allows me to keep ~4 columns. Would you know how I could keep everything?

Hi,

Can you share result datatable you expect? As grouping information for manager as key, we need to clarify how handle information for employee etc. For example, join each items like mail address or format like Name <mailaddress> style etc.

Or another approach is to make dictionary for employee information as the following .
We can get each information from mail address.

dict = dt.AsEnumerable.ToDictionary(Function(r) r("Employee Email").ToString,Function(r) r("Employee Name").ToString)

Regards,