How to send emails to multiple users by reading a column

Hi everyone,

I would like to ask how can I send emails to multiple users by reading the file name of an excel file and match its respective emails in a column?

For example:
By reading the file name, I can match its Name to its respective email in column C and send it via outlook.

Eren.xlsx (8.3 KB)
Rohan.xlsx (8.3 KB)
Thomas.xlsx (8.3 KB)

File name Eren, Rohan and Thomas can match the emails in column C in name + details excel file.
Name + Email Details.xlsx (9.5 KB)

image

Hi!

Read the excel using read range output as ->Dt_Out

Take one for each roe in DataTable pass the Dt_oUT

Take one assign activity create one variable called Mail pass the value like this

CurrentRow("Email").ToString.Trim

Take one Send SMTP Mail Message or Send Outlook Mail Message activity-> Fill the necessary details

in the to field pass the Mail variable which we created earlier

Regards,
NaNi

1 Like

Hi,

I am assuming your files will be in a folder and you have read the Name +Email excel to a Datatable named (v_InputDataTable), please follow below steps

  1. Read the files from the folder using Directory.GetFiles(“FolderName”,“*.xlsx”) which will give an output as Array variable
  2. Use Foreach Loop and give the array variable as input for the loop, and inside loop have a Assign activity as below:
    String FileName = new System.IO.FileInfo("your file path ").Name
  3. FileName variable will give the name of the file which you can use it in the select query
  4. In another assign use as below to filter:
    string Email_ID = v_InputDataTable.AsEnumerable.Where(Function (x) x(“Name”).Tostring = FileName).ToList(0).Item(“Email”).Tostring
1 Like

Hi,
You can use the below steps:

Read range activity : read the excelsheet to get the datatable(dt)
assign activity : listEmail = dt.AsEnumerable.Select(Function (row) row.Field(Of String)(“Email”)).tolist
Assign activity : emails = String.Join(“;”,listEmails.ToArray))
Send outlook mail : To = emails

1 Like

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