I need to send an email to each driver with their own document attached. Let me explain. I have a folder containing all the pdf files to send to each driver. Each pdf file is renamed with the license plate assigned to the driver. On an excel file I have on one column all the license plates and on another column the driver’s email to send the file to. For each email on the excel file, I must then attach the file corresponding to the license plate in the folder.
Use the Excel Application Scope to choose the excel file.
Add a Read Range activity within the Excel Application Scope (Have the Add Headers options enabled if the first row is a header). Assign the Output to a DataTable.
Assign the folder path to a variable.
Add a For Each Row activity to read the rows from the Data Table.
Get the column that has the licence number.
Create the new file path by adding this licence number and the file extension to the variable from Step 3.
Get the email address from the column that holds the email address
Use the relevant Send Mail activity . In the To field add the email address received from Step 7, and in Attach Files , give the path of the variable from Step 6.
Store all pdf files in one folder and use the following assign activity to get the list of file path of PDF files
list_1 = Directory.GetFiles(folderpath)
Use read range activity to read the excel file and store in dt1
Use for each activitiy to loop through each PDF files ( for each file in list_1)
Inside for each do the following activity
a) use lookup datatable activitiy to lookup for file name in excel file and extract the corresponding email to it
In property panel of look up datatable activity property panel do the following
Lookup value : Path.GetFileName(file)
Datatable : dt1
Other values u can set Accordingly
b) after getting email corresponding to license plate use mail activity to sent email with attachment file path as file (through which we are iterating)