SSIS - Store multiple messages in one variable and send one email
Hi All, I have a ftp task that downloads multiple files in a forloop container. I have a send email task for each file download that failed to email the error msg and the file that failed. But i need to modify it and send one email with all the files that failed instead of multiple emails for each failed download file. I have a variable which stores each file that failed to be downloaded so i need to store all the failed downloads in one variable. The issue i have is the ftp task and the send email task are in the forloop container. Any help appreciated!
May 18th, 2011 11:33am

I suggest you introduce a new Package level variable to store the list of files. Then inside the very ForEach Loop add a Script Task to just append a new file name to it. Take the Email Task outside the ForEach loop and set a precedence constraint to check if that new variable is filled, if yes you send the email. Example would be this link http://whiteknighttechnology.com/cs/blogs/brian_knight/archive/2005/12/30/57.aspx but you use the text and you append it.Arthur My Blog
Free Windows Admin Tool Kit Click here and download it now
May 18th, 2011 11:51am

Hey ArthurZ, We meet again. Hey thanks for response i'll try that. The only thing is I have a forloop container not a foreach loop and i have multiple steps that im error checking in the container and sending emails. So the script task will be writing to this variable right? And what data type should this variable be? I read something abt using the object data type for this. And do you have any examples of script task for this?
May 18th, 2011 1:36pm

Hi. Yes, the script will take care of this string (DT_STR) variable, also I see no problem with the ForLoop. I would only want you to be aware of the string limitation in length of 8,000 chars, but I believe it must be sufficient to be used in an email body. More help (not sure if you are on 2008, giving 2005 VB examples): Setting a variable in Script Task: http://www.techrepublic.com/blog/programming-and-development/using-sql-server-2005-integration-services-variables-from-a-script-task/666 Sending Email Message with variable as its body: http://www.mssqltips.com/tip.asp?tip=1731Arthur My Blog
Free Windows Admin Tool Kit Click here and download it now
May 18th, 2011 1:57pm

Thanks i'll check out the examples you provided.
May 18th, 2011 2:08pm

1) Object variable would do to store all the list of error messages. 2) On the other hand , I could think of an array list which I tried long back. Check this thread http://social.msdn.microsoft.com/Forums/en/sqlintegrationservices/thread/288d9014-0934-4488-8fe0-2e70e45ceaed. The thread discusses about extracting each item from Array list, you could do a reverse.Happy to help! Thanks. Regards and good Wishes, Deepak.
Free Windows Admin Tool Kit Click here and download it now
May 18th, 2011 3:01pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics