Let's say you need to create a SSIS package, creates 2 files and emails the files to someone.
Your Package-something like this:
Double-click the Send Mail task to open the Send Mail task Editor (shown below).
Fill in all the relevant fields, such as to, Subject, etc.
Click the Attachments text area, and then click the ' ellipsis button ' to open the file dialog. Navigate to and select the files you need. You can do this multiple times if necessary to add all the files for you need.
Note that when multiple files is attached, SSIS would automatically put a vertical bar/pipe character ("|") between each F Ile. However, chances is if that's all of your needed to does you would just do it via Outlook and is done.
It's likely that's need to make the this dynamic so that's can automate your process to automatically create and name yo ur files dynamically, and then attach the files to the email. For this, you'll need to use Expressions to create your files, and to set the ' Fileattachements ' property.
To make your filenames dynamic, click the Expressions ellipsis in the Properties pane for the Connection Manager for the F Ile.
Choose the "ConnectionString" property and then set the expression in the expression Builder.
In the example below, the current date was added to the end of the the File1, so it each day when your package runs, you'll There is a different filename–for example, file1_20110519, file1_20110520, and so on.
So, now and you have the dynamic filenames, you need to make your Send Mail task ' s "fileattachments" property dynamic.
Open The Send Mail Task Editor by double clicking on the Send Mail task.
Click the Expressions option on the left-hand side of the Task Editor.
Click the text box to the right of Expressions and then click the "ellipsis button".
Select the "Fileattachments" property and then click the ellipsis button to open the Expression Builder.
So, let's say you needed to attach the 2 files, File1_yyyymmdd.txt and file2_yyyymmdd.txt where YYYYMMDD are the current date .
Create your Expression to being something like this:
You could has also created a package variable this stores the current date in the format YYYYMMDD and use the variable in stead of the long expression above. For example, if derived the date and stored in a variable called user::todaysdate, then your "fileattachment" Expressi On would look something like this:
"C:\\projects\\file1_" + @[user::todaysdate] + "|" + "C:\\PROJECTS\FILE2_" + @[user::todaysdate]
How to attach multiple files on the Send Mail Task in SSIS