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. api权限管理系统与前后端分离实践

    https://segmentfault.com/a/1190000014368885

  2. 【SaltStack官方版】—— STORING JOB RESULTS IN AN EXTERNAL SYSTEM

    STORING JOB RESULTS IN AN EXTERNAL SYSTEM After a job executes, job results are returned to the Salt ...

  3. Jenkins自动打包并部署(以java -jar形势运行)

    1.打包 与平常maven项目打包一致,不再赘述 2.杀死原有进程 通过 pid=`ps -ef|grep $APP_NAME|grep -v grep|awk '{print $2}' ` 获取当前 ...

  4. 【NOIP2016提高A组模拟8.15】Throw

    题目 分析 首先对于一个状态(a,b,c),假定a<=b<=c: 现在考虑一下这个状态,的转移方案: \[1,中间向两边跳(a,b,c)-->(a*2-b,a,c).(a,b,c)- ...

  5. 结合webpack实现children子路由,抽离路由模块

    demo结构 package.json.webpack.config.js.index.html与上一篇博客相同. main.js // 这是项目的入口js文件 // import $ from 'j ...

  6. JPA学习(四、JPA_映射关联关系)

    框架学习之JPA(四) JPA是Java Persistence API的简称,中文名Java持久层API,是JDK 5.0注解或XML描述对象-关系表的映射关系,并将运行期的实体对象持久化到数据库中 ...

  7. Codeforces 960F Pathwalks ( LIS && 树状数组 )

    题意 : 给出若干个边,每条边按照给出的顺序编号,问你找到一条最长的边权以及边的编号同时严格升序的一条路径,要使得这条路径包含的边尽可能多,最后输出边的条数 分析 :  这题和 LIS 很相似,不同的 ...

  8. [Usaco2010 Dec]Treasure Chest 藏宝箱

    题目链接:点这里 Solution: 刚开始以为是博弈论,然而不是... 首先考虑n方dp,设f(l,r)为只有\(l\)到\(r\)区间的钱的先手最大获利 那么我们可以得到式子f(l,r)=sum( ...

  9. x-pack邮件报警功能

    1):修改elasticsearch.yml xpack.notification.email.account: work:   profile: standard   email_defaults: ...

  10. 聊聊 Vue 的双向数据绑定,Model 如何改变 View,View 又是如何改变 Model 的

    todo defineProperty() 参考: https://www.cnblogs.com/wangjiachen666/p/9883916.html