Howto email list of people with SendMail Task

  • I need to have an SSIS package perform a sendmail task but everytime it runs, the email TO: element might be a different account, therefore I need the TO: to be the result of a query against a table containing the email address of the active person/people to contact.

    The SendMail task does not seem to allow this functionality as the TO: element must be hard coded.

    Any ideas how to accomplish this?

    TIA

    Neil.

  • You can put the email addresse(s) in a variable and then use the variable in a expression in the task. Open the send mail task for Edit and look at the expressions tab. You can set the ToLine property to a variable with a Expression.

  • Thanks for the tip, I've now created a variable 'EmailTo' and hard coded an email address to it and assigned that to the ToLine expression as you suggested.

    The only problem is that I won't know who to email until runtime as the recipient(s) will be dependant upon some record(s) in the application database, such as which engineer is on call therefore it needs to be able to populate the variable from a database query.

    Thanks

    Neil.

  • Whoops! Here is the Microsoft link.

    http://msdn2.microsoft.com/en-us/library/ms141689.aspx

     

  • Take a look at the examples on this site http://www.sqlis.com/default.aspx

    and this article http://www.sqlis.com/58.aspx It is more than you need but I think you will find it helpful.

    Finally, here is Microsoft's take on it. How to: Map Result Sets to Variables in an Execute SQL Task 

     

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply