This Control Flow will place the query results in the body of the message and deliver only if it contains records.
[Execute SQL Task] ---> [XML Task] -f(x)-> [Send Mail Task]
1) The Execute SQL Task returns the query results as XML.
2) An XML Task calculates the row count of the results.
3) The constraint uses an expression to determine if a message should be sent.
4) The Send Mail Task uses an expression to populate the body of the message.
Here's a list of variables and some of the task properties for this type of solution.
Variables:
varRowCount : Package : String
varResults : Package : String
Execute SQL Task properties:
ResultSet: XML
SQLStatement: SELECT col1,col2 FROM table1 FOR XML AUTO;
Result Name: 0
Variable Name: User::varResults
XML Task properties:
OperationType: XPATH
SourceType: Variable
Source: User::varResults
SaveOperationResult: True
Destination: User::varRowCount
SecondOperand: count(//table1)
Send Mail Task properties:
MessageSource : @[User::varResults]