Friday, March 30, 2012

Putting System Variables in a Send Mail Task

KB Article 906547 suggest that it's possible to have system variables in the Subject & Body of a Send Email Task. Such as this:

"Package>>> " + @.[System::PackageName] +" was executed at>>> " + (DT_WSTR, 40) @.[System::StartTime] + " by user>>> " + @.[System::UserName] + " on Machine>>> " + @.[System::MachineName]

Or this in an OnError event handler:

"Error in the task: " + @.[System::SourceName] + "with the ID: " + @.[System::SourceID] + " has failed at: " + (DT_WSTR, 20) @.[System::ContainerStartTime] + "."

But when I do this I just get this exact text, no variables.

I'm obviously missing something basic but I can't find it. Can anyone offer a suggestion please?

I believe you are entering ""Package>>> " + @.[System::PackageName] +" was executed at>>> " + (DT_WSTR, 40) @.[System::StartTime] + " by user>>> " + @.[System::UserName] + " on Machine>>> " + @.[System::MachineName]" text directly in the 'Subject' field.

Since this is an expression you cannot enter in the Subject field directly instead you need to specify it as an expression.

Clear the Subject field - Select Expressions - Expand Expressions - Select 'Subject' for the property drop down - Specify "Package>>> " + @.[System::PackageName] +" was executed at>>> " + (DT_WSTR, 40) @.[System::StartTime] + " by user>>> " + @.[System::UserName] + " on Machine>>> " + @.[System::MachineName] in the Property field.

Thanks,
Loonysan

|||

Yes, that was it. Sorry I should have seen that I needed to put the items as an expression.

Thank You for your help.

No comments:

Post a Comment