Multiple Email Attachments

  • Hi Guys

    I have a folder that has a number of pdf files within it. This folder is regularly updated and may not always have the same amount of files within it.

    The thing I am trying to do is to use the Send Mail Task to send all the files as attachments.

    I understand that I could use a variable and place the file names in it, but as the files are not always going to be the same this wouldn’t work.

    Anyone have any ideas?

    Thanks 😀

  • rcr69er (3/16/2009)


    Hi Guys

    I have a folder that has a number of pdf files within it. This folder is regularly updated and may not always have the same amount of files within it.

    The thing I am trying to do is to use the Send Mail Task to send all the files as attachments.

    I understand that I could use a variable and place the file names in it, but as the files are not always going to be the same this wouldn’t work.

    Anyone have any ideas?

    Thanks 😀

    You have to construct the list of attachments dynamically. You have to create a script task for this. Check the code below:

    Imports System.IO

    ...

    Dim filesList As String = String.Join("|", Directory.GetFiles("c:\MyFolder", "*.pdf"))

    Dts.Variables("Attachments").Value = filesList

    Setup MyFolder to your folder and setup ReadWriteVariables Attachments or whatever variable you want to use. After you do this, you have to create Expression in your Send Mail Task and setup FileAttachments property with the variable holding the attachments list (Attachments).

    ---
    SSIS Tasks Components Scripts Services | http://www.cozyroc.com/

  • Hey

    Thanks for that, I'll try it out and let you know the result!

    Thanks

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

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