Select the product you need help with
- Internet Explorer
- Windows Phone
- More products
How to create a dynamic subject or message for the Send Mail task in SQL Server 2005 Integration Services
Article ID: 906547 - View products that this article applies to.
You can create a Microsoft SQL Server 2005 Integration Services (SSIS) package by using SQL Server Business Intelligence Development Studio. When you create this package, you can create an expression for a property of the SSIS package to update or to populate the property at runtime. For example, if the SSIS package contains a Send Mail task, you can create an expression for the Subject property and for the MessageSource property. You can use the Subject property expression to dynamically update the subject of an e-mail message. You can use the MessageSource property expression to dynamically update variables in the e-mail message, such as variables that are populated by a Row Count transformation.
This article discusses how to create a dynamic subject or message for the Send Mail task.
The following is a sample property expression for the Subject property in a Send Mail task.
If you use this sample property expression, the subject of an e-mail message is updated dynamically. The subject will include the following information:
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:
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.
This sample expression uses the following system variables:
For more information, see the following topics in SQL Server 2005 Books Online: