This article discusses how to create a dynamic subject or message for the Send Mail task.
"Package>>> " + @[System::PackageName] +" was executed at>>> " + (DT_WSTR, 40) @[System::StartTime] + " by user>>> " + @[System::UserName] + " on Machine>>> " + @[System::MachineName]
- Text information
In this example, the e-mail message subject includes the "Package>>> " text information.
- System variables
The e-mail message includes the following system variables:
The package name.
The time that the package was executed.
The user who executed the package.
The name of the computer on which the package was executed.
To specify that an e-mail message be sent only if the row count is smaller than a certain value, modify the control flow by using precedence constraints. To do this, follow these steps:
- In SQL Server Business Intelligence Development Studio, right-click Data Flow Task, and then click Add Precedence Constraint.
- Double-click the precedence constraint that you just created.
- In the Precedence Constraint Editor dialog box, click Expression and Constraint in
- In the Expression box, type the following expression:@myrowcount < 2
- In the Precedence Constraint Editor dialog box, click OK.
Additionally, you can use the Send Mail task as part of an error handler. For example, you may want to send an e-mail message to administrators when an SSIS package does not execute. To do this, create an OnError event handler for the package, and then add a Send Mail task to the event handler. Create a subject property expression that captures the time that the package is executed, the start time of the container, or the start time of the event handler from the relevant system variables. For example, create an expression that is similar to the following.
"Error in the task: " + @[System::SourceName] + "with the ID: " + @[System::SourceID] + " has failed at: " + (DT_WSTR, 20) @[System::ContainerStartTime] + "."
The time when the package was executed.
The time that the container started.
The time that the event handler started.
- "Using Property Expressions in Packages"
- "How to: Create a Property Expression"
- "Advanced Integration Services Expressions"
- "Precedence Constraints"
- "Setting Precedence Constraints on Tasks and Containers"
- "Integration Services Event Handlers"
Article ID: 906547 - Last Review: Mar 29, 2017 - Revision: 2