Chapter 15

Using the Send Mail Task

The Send Mail Task sends e-mail via Simple Mail Transfer Protocol (SMTP) from a SQL Server Integration Services (SSIS) package. This task enables you to receive information about the package that can be passed into the mail task through variables—system variables or user-defined variables. The Send Mail Task is most commonly used as a notification tool. The system variables in an SSIS package hold information such as package start time, errors, and warnings.

You can place the Send Mail Task at the end of a Control Flow to send e-mail on the successful completion of a package. The event handler of a package is also a great place to place the Send Mail Task (event handlers are covered in Lesson 48). You can place the task in the OnPreExecute Event Handler to notify you via e-mail that a package has begun. The OnPostExecute Event Handler can send mail at the end of a package showing the start and end for a package, therefore enabling you to track the run time of a package. When you place a Send Mail Task in the OnError or the OnWarning Event, you can be notified when an error or warning occurs anytime during the running of a package.

You can also use the Send Mail Task to send files, because it can send attachments. A Data Flow can exist in a package that creates a file, and a Send Mail Task can then send that file via e-mail. The file can be created in a Data Flow or by a File System Task. It can also be any file not created or altered by the package. ...

Get Knight's Microsoft SQL Server 2012 Integration Services 24-Hour Trainer now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.