Thursday, December 16, 2010

Use formatted lines in Send Mail Task in SSIS package

We often want to format the information in the emails. In Send Mail Task of a SSIS packages, I wanted, instead of sending out information in an English sentence like this:

"At $datetime on Machine $machinename SSIS packge $packagename imported $Rowcount rows from source file $filename."

I would rather like to put each piece of information on a different line. To do that, In Send Mail Task create an Expressions for MessageSource. In Expression Builder, write something like this:

"\nMachine Name: " + @[System::MachineName]  +
"\nPackage Name: " + @[System::PackageName] +
"\nExecuted Time: " +  (DT_WSTR, 30)@[System::StartTime] +
"\nSource File Name: " + @[User::FileName]  +
"\n\nRows Imported: "  + (DT_WSTR, 8)@[User::RowCount]  + "\n"

As you can see, "\n" is used to get line break.

Done.

No comments:

Post a Comment