How to attach multiple files in the Send Mail Task in SSIS
Let’s say you need to create a SSIS package that creates 2 files and emails the files to someone.
Your package may look 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 in 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 you need.

Note that when multiple files are attached, SSIS will automatically put a vertical bar/pipe character (“|”) between each file. However, chances are if that’s all you needed to do you would just do it via Outlook and be done.
It is likely that you need to make this dynamic, so that you can automate your process to automatically create and name your files dynamically, and then attach the files to the email. For this, you will 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 file.
Choose the “ConnectionString” property and then set the Expression in the Expression Builder.
In the example below, the current date is added to the end of the File1, so that each day when your package runs, you will have a different filename – for example, File1_20110519, File1_20110520, and so on.

So, now that you have 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 in 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 say you needed to attach the 2 files, File1_yyyymmdd.txt and File2_yyyymmdd.txt where yyyymmdd is the current date.
Create your Expression to be something like this:

You could have also created a package variable that stores the current date in the format yyyymmdd and use the variable instead of the long expression above. For example, if you derived the date and stored in a variable called User::TodaysDate, then your “Fileattachment” expression would look something like this:
“C:\\Projects\\File1_” + @[User::TodaysDate] + “|” + “C:\\Projects\File2_” + @[User::TodaysDate]
How to attach multiple files in the Send Mail Task in SSIS的更多相关文章
- SSIS Send Mail
在SSIS中Send Mail的方法主要有三种,使用Send Mail Task,使用Script Task和使用存储过程msdb.dbo.sp_send_dbmail. 一,使用Send Mail ...
- Uploading multiple files asynchronously by blueimp jquery-fileupload
Uploading multiple files asynchronously by blueimp jquery-fileupload Solved. Fiddle: http://jsfidd ...
- 基于Picture Library创建的图片文档库中的上传多个文件功能(upload multiple files)报错怎么解决?
复现过程 首先,我创建了一个基于Picture Library的图片文档库,名字是 Pic Lib 创建完毕后,我点击它的Upload 下拉菜单,点击Upload Picture按钮 在弹出的对话框中 ...
- How to effectively work with multiple files in Vim?
Why not use tabs (introduced in Vim 7)? You can switch between tabs with :tabn and :tabp, With :tabe ...
- Error:Error converting bytecode to dex: Cause: com.android.dex.DexException: Multiple dex files define Lcom/lidroid/xutils/task/TaskHandler;
Error:Error converting bytecode to dex: Cause: com.android.dex.DexException: Multiple dex files defi ...
- How to Upload multiple files to documentLibrary in one time
In a Sharepoint 2013 website,we can upload one file to the documentlibrary by click "Uploa ...
- mailsend - Send mail via SMTP protocol from command line
Introduction mailsend is a simple command line program to send mail via SMTP protocol. I used to sen ...
- 发送邮件的三种方式:Send Mail Message
发送邮件的三种方式: 1.VBS 执行vbs脚本文件的程序为: system32文件下的 NameSpace = "http://schemas.microsoft.com/cdo/conf ...
- [SCSS] Organize SCSS into Multiple Files with Partials
Tired of dealing with monolithic CSS files? Are requests for multiple CSS files hurting your perform ...
随机推荐
- WIN 7 的vs2008 试用版评估期结束的解决方法
1. 在VS2008安装目录下把Setup/setup.sdb文件中的 [Product Key] T2CRQGDKBVW7KJR8C6CKXMW3D 改成 [Product Key] PYHYPWX ...
- C#之扩展方法 default(T)
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- guava中Multimap、Multiset使用
guava中的Multimap接口 Multimap和java.util.Map接口没有任何继承关系.同Map一样,也是放键值对,但是Multimap的值是一个集合.同样支持泛型,假如键值对的key的 ...
- XML DOM (Document Object Model) 定义了访问和操作 XML 文档的标准方法。
XML DOM DOM 把 XML 文档视为一种树结构.通过这个 DOM 树,可以访问所有的元素.可以修改它们的内容(文本以及属性),而且可以创建新的元素.元素,以及它们的文本和属性,均被视为节点. ...
- POJ 2492 A Bug's Life (带权并查集 && 向量偏移)
题意 : 给你 n 只虫且性别只有公母, 接下来给出 m 个关系, 这 m 个关系中都是代表这两只虫能够交配, 就是默认异性, 问你在给出的关系中有没有与异性交配这一事实相反的, 即同性之间给出了交配 ...
- Springboot 构建http服务,返回的http行是'HTTP/1.1 200' 无状态码描述 客户端解析错误
————————————————————————————————————————— *** 响应的数据格式 HTTP/1.1 200 OK Server: Apache-Coyote/1.1 A ...
- [C++基础] 纯虚函数
整理摘自https://blog.csdn.net/ithomer/article/details/6031329 1. 申明格式 class CShape { public: ; }; 在普通的虚函 ...
- pycharm selenium 安装firefox驱动和Google驱动教程
一.下载Firefox浏览器或Google浏览器 下载渠道有很多,直接下载最新版的就可以了. 二.下载驱动 Firefox驱动 地址:https://github.com/mozilla/geckod ...
- [HDU3072]:Intelligence System(塔尖+贪心)
题目传送门 题目描述 “这一切都是命运石之门的选择.”试图研制时间机器的机关SERN截获了中二科学家伦太郎发往过去的一条短 信,并由此得知了伦太郎制作出了电话微波炉(仮).为了掌握时间机器的技术,SE ...
- [LeetCode]-009-Palindrome_Number
Determine whether an integer is a palindrome. Do this without extra space. Some hints: Could negativ ...