In this tutorial, we'll copy the data from a CSV file to an existing Excel file and then we'll attach the Excel file to an email and send the email from Outlook.
We will create a project and start by adding an Excel File Card to indicate the Excel file where we want to copy the data. Inside the card, we will add a Read CSV activity to indicate the CSV file to copy from and where in the Excel file to copy to. We'll then add an Outlook Account Card to indicate the Outlook account to use and inside it we will add a Send Outlook Email activity to send the email.
Step 1: Set up the project and get the necessary files.
- Create a new project using the default settings.
- Download and extract the archive with the automation project in this example using the button at the bottom of this page, then copy the files A.csv and B.xlsx to your project folder.
Step 2: Add the Excel file to the project.
- Click on the Designer panel and then, in the Common Scenarios section of the search box at the top of the screen, select Use Excel File, and browse to and select the file
B.xlsx
. An Excel File Card activity is added to the Designer panel. - In the activity, in the field And reference it later as enter
ExcelB
.
You have indicated that you will work on the file B.xlsx that is known in your automation as ExcelB.
Step 3: Add an activity to copy the data from the CSV file to the Excel file.
- Click inside the Excel File Card, and then find the Read CSV activity in the search box at the top of the screen and select it. The activity is added inside the Excel File Card.
- In the Read CSV activity:
- Click next to the Read from file field, and then browse to and select the file A.csv.
- Click on the right side of the Output to field, and then select ExcelB > Indicate in Excel. The spreadsheet is opened in Excel. Because there is already data in the file and we want to keep it, select the first cell in the first empty row (cell A7), and then click Confirm. The field is updated with your selection [ExcelB] Sheet1!A7.
You have indicated that you want to copy the data from the CSV file A.csv to the file ExcelB in Sheet1 starting with the A7 cell.
Step 4: Add the Outlook account to the project and send the email.
- In the Activities panel, select the Outlook tab and drag the Outlook Account Card and drop it below the Excel File Card. An Outlook Account Card is added to the Designer panel.
- In the activity, the default email account is already selected in the Select mail account field. If you want to use a different account, select it from the drop-down menu.
In the And reference it later as field, leave the default valueOutlook
as the name under which to refer to the account in the automation. - In the Activities panel, drag the Send Outlook Email activity and drop it inside the Outlook Account Card.
- In the Send Outlook Email activity:
- Click on the right side of the From account field, and then select Outlook.
- Click on the right side of the To field, and then select Text. In the Text Builder window, enter an email address where to send the email. For example, you can enter your own email address to send the email to yourself.
- Click on the right side of the Subject field, and then select Text. In the Text Builder window, enter a subject for the email, for example
Updated Excel File
. - Click on the right side of the Body field, and then select Text. In the Text Builder window, enter text for the body of the email, for example
See attachment
. - For Attachments, select Files, then click next to the field, and then browse to and select the file B.xlsx.
- Click Save in the ribbon menu to save the automation, then click Run to execute the automation.
The data from A.csv is copied to B.xlsx, and then attached to a mail message and sent using the details configured in the Send Outlook Email activity.
Updated 2 years ago