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. 【UOJ#394】[NOI2018] 冒泡排序

    题目链接 题意 求有多少个字典序严格大于给定排列 \(q_i\) 的排列满足其逆序对数(冒泡排序需要交换的次数)达到下限 \(\frac{1}{2}\sum_{i=1}^n |i-p_i|\) Sol ...

  2. vue导航菜单动态展示

    地址:https://blog.csdn.net/qq_31126175/article/details/81875468      

  3. UVA 11090 : Going in Cycle!! 【spfa】

    题目链接 题意及题解参见lrj训练指南 #include<bits/stdc++.h> using namespace std; const double INF=1e18; ; ; in ...

  4. spark读取kafka数据 createStream和createDirectStream的区别

    1.KafkaUtils.createDstream 构造函数为KafkaUtils.createDstream(ssc, [zk], [consumer group id], [per-topic, ...

  5. tf.concat( )和tf.stack( )

    相同点:都是组合重构数据. 不同点:concat()不改变维数,而stack改变了维数(待定!!!) tf.concat是连接两个矩阵的操作,请注意API版本更改问题,相应参数也发生改变,具体查看AP ...

  6. Nginx模块开发实验

    工作原理: 当nginx接到 一个http请求之后,会找通过查找配置文件,并在配置文件中找到相应的地址映射,该地址也叫location block,而location中配置的文件会启动 相应的bloc ...

  7. Python简单雷达图绘制

    import numpy as npimport matplotlib.pyplot as pltimport matplotlibmatplotlib.rcParams['font.family'] ...

  8. [CF1093G]Multidimensional Queries:线段树

    分析 非常有趣的一道题. 式子中的绝对值很难处理,但是我们发现: \[\sum_{i=1}^{k}|a_{x,i}-a_{y,i}|=\sum_{i=1}^{k}max(a_{x,i}-a_{y,i} ...

  9. [IOI2008/BZOJ1791 岛屿](处理基环树的小技巧&基于bfs树形DP)

    IOI2008/BZOJ1791 岛屿 题目大意是在一个基环树森林里求每一棵基环树的直径①的和. 其实就是树的直径的基环树升级版.我们先把环找出来,然后从环上的每一个节点x出发,并且不经过环上其他节点 ...

  10. Hashtable 和 HashMap 的区别是:

    HashMap 是内部基于哈希表实现,该类继承AbstractMap,实现Map接口 Hashtable 线程安全的,而 HashMap 是线程不安全的 Properties 类 继承了 Hashta ...