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的更多相关文章

  1. SSIS Send Mail

    在SSIS中Send Mail的方法主要有三种,使用Send Mail Task,使用Script Task和使用存储过程msdb.dbo.sp_send_dbmail. 一,使用Send Mail ...

  2. Uploading multiple files asynchronously by blueimp jquery-fileupload

    Uploading multiple files asynchronously by blueimp jquery-fileupload   Solved. Fiddle: http://jsfidd ...

  3. 基于Picture Library创建的图片文档库中的上传多个文件功能(upload multiple files)报错怎么解决?

    复现过程 首先,我创建了一个基于Picture Library的图片文档库,名字是 Pic Lib 创建完毕后,我点击它的Upload 下拉菜单,点击Upload Picture按钮 在弹出的对话框中 ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. 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 ...

  8. 发送邮件的三种方式:Send Mail Message

    发送邮件的三种方式: 1.VBS 执行vbs脚本文件的程序为: system32文件下的 NameSpace = "http://schemas.microsoft.com/cdo/conf ...

  9. [SCSS] Organize SCSS into Multiple Files with Partials

    Tired of dealing with monolithic CSS files? Are requests for multiple CSS files hurting your perform ...

随机推荐

  1. 【NOIP2017提高组模拟6.27】C

    题目 蜘蛛精大爷是世界上最爷的爷,ta的图论专著<蜘蛛精大爷教你学做人OI之图论>正在热卖,只要233美元一本,每人限购一本......在某弱的不懈要求下,ta给某弱出了一道题,然而某弱太 ...

  2. 【leetcode】Basic Calculator III

    题目如下: Implement a basic calculator to evaluate a simple expression string. The expression string may ...

  3. F12谷歌开发者工具preserve log

    谷歌开发者工具里面这个preserve log :保留请求日志,跳转页面的时候勾选上,可以看到跳转前的请求,也可适用于chrome开发者工具抓包的问题

  4. ubuntu 7z解压

    安装方法:     sudo apt-get install p7zip 解压文件:     7z x manager.7z -r -o /home/xx 解释如下: x 代表解压缩文件,并且是按原始 ...

  5. C# 自定义类中括号取值 测试

    public class ABC : Hashtable{} static class Program { public static ABC a= new ABC(); static void Ma ...

  6. POJ 2492 A Bug's Life (带权并查集 && 向量偏移)

    题意 : 给你 n 只虫且性别只有公母, 接下来给出 m 个关系, 这 m 个关系中都是代表这两只虫能够交配, 就是默认异性, 问你在给出的关系中有没有与异性交配这一事实相反的, 即同性之间给出了交配 ...

  7. luogu P1352 没有上司的舞会 x

    P1352 没有上司的舞会 题目描述 某大学有N个职员,编号为1~N.他们之间有从属关系,也就是说他们的关系就像一棵以校长为根的树,父结点就是子结点的直接上司.现在有个周年庆宴会,宴会每邀请来一个职员 ...

  8. (56)Linux驱动开发之二

                                                                                             内核基础   1.li ...

  9. 2017年广东省ACM省赛(GDCPC-2017)总结

    今年第一次参加省赛(也是第一次参加这类比赛),既有点惊喜又有点紧张,前一晚没有怎么睡好,有点怕今年打铁,虽然说大一打铁也说的过去,可是谁也不想打铁. 一开始比赛的时候我一开始没有去看题,而是把我们队的 ...

  10. Oracle JET Model 数据获取与使用

    Oracle JET 应用程序数据可以来自生成 JSON 数据的任何 Web 数据源,例如 REST 服务,服务器发送事件(SSE)或 WebSocket .此外,Oracle JET 还提供了基于 ...