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 a Use Excel File activity to indicate the Excel file where we want to copy the data. Inside this activity, 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 a Use Desktop Outlook App activity to indicate the Outlook account to use and inside it we will add a Send Email activity to send the email.
Step 1: Set up the project and get the necessary files.
- Create a new blank 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 Add activity in the Designer panel, and then find the Use Excel File activity in the search box at the top of the screen and select it. A Use Excel File activity is added to the Designer panel.
- In the activity:
- Click Browse next to the Excel file field, and then browse to and select the file
B.xlsx
- In the field Reference as, enter
ExcelB
.
You have indicated that you will work on the file B.xlsx that is known in your automation as ExcelB.
- Click Browse next to the Excel file field, and then browse to and select the file
Step 3: Add an activity to copy the data from the CSV file to the Excel file.
- Click Add activity inside the Use Excel File activity, 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 Use Excel File activity.
- In the Read CSV activity:
- Click Browse next to the Read from file field, and then browse to and select the file A.csv.
- Click Plus 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 Mail tab and drag the Use Desktop Outlook App activity and drop it below the Use Excel File activity. A Use Desktop Outlook App activity is added to the Designer panel.
- In the activity, the default email account is already selected in the Account field. If you want to use a different account, select it from the drop-down menu.
In the Reference as field, leave the default valueOutlook
as the name by which to refer to the account in the automation. - In the Activities panel, drag the Send Email activity and drop it inside the Use Desktop Outlook App activity.
- In the Send Email activity:
- Click Plus on the right side of the From account field, and then select Outlook.
- Click Plus 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. If you leave the Is draft option selected, the automation does not send the email, it instead saves the email to the Outlook Drafts folder.
- Click Plus 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 Plus 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 Browse next to the field, and then browse to and select the file B.xlsx.
- Click Save in the StudioX ribbon 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 Email activity.
Updated 2 years ago
See Also
Tutorials |