Build email message from OLE DB recordset in SSIS

  • I am working in SQL Server 2005 SSIS.

    I have a package that rights errors out to an error table. I want to send an email with the errors in the message body.

    In my package I have an SQL Task using a connection type of OLE DB.

    I have the recordset going into a variable.

    The connection then goins to a Script Task.

    In the script, I want to loop through the recordset to build the email message body and then send the email.

    First, is this the best way to do what I want. I could export the records to an Excel file and email the Excel file, but this

    seems a little clumsy.

    Does anyone have a sample script of what I want to do?

    Any help would be great.

    Terry

  • Here is a suggestion, I'm guessing there may be a better way, but this may get you started.

    Run the query to generate the error list using an execute sql task and store the result set in an object type variable. then use a foreach loop that uses the ADO enumerator and loop through the recordset appending the rows to a string variable. Use this variable as the email body.

  • Hi,

    Thanks for the suggestion. If I don't get any help with the script, I'll give you idea a try.

    I was hoping to create a formatted email and not a dump of the data to the email.

    Terry

  • Terry,

    Not going to happen in a format fashion in the message sending out. Why would want to put errors in the message of an email anyway? I would put it in an excel sheet and have it added in an attachment. It's the cleanest way besides a flat file and user friendly for users. Sorry to bust your bubble but I tried it and it just never came out clean or formatted.

    leisha

    MCSE SQL Server 2012\2014\2016

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

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