I recently created an SSIS package that runs a batch file using the Execute Process Task. If the batch process is unsuccessful I wanted to email the result message to an email account. This is a straight forward task, however, I had a little confusion I thought I’d share in case you come across the same issue.
Next, I created a Send Mail Task connected to the Execute Process Task by a Failure Precedence Contstraint. In the Send Mail Task I configured the MessageSourceType property to Variable and the MessageSource property to be an expression using the User::ErrorResult variable from the Execute Process Task and some other text concatenated together.
Upon testing I received an error:
Error: 0xC0014054 : Failed to lock variable %string% The variable cannot be found. This occurs when an attempt is made to retrieve a variable from the Variables collection on a container during execution of the package, and the variable is not there. The variable name may have changed or the variable is not being created.
After troubleshooting I found the Send Mail Task’s MessageSourceType property needed to be set to Direct Input to properly evaluate my expression that built the MessageSource. Configuring the mail task this way wasn’t intuitive to me at first but it does make sense. The expression I created resulted in a string which needed to be DIrect Input into the MessageSource property.