Provide variables for the from and to addresses in Email Task

  • Hi,

    I am new to SSIS and want to use a variable for the from and to address for the Email Task. I have declared a package scope variable GV_FromAddress and tried to use it in the from as @GV_FromAddress. Any help?

  • ok,, here's how I did that..

    1, setup your variables in the ssis package like you suggest.. then on the properties of the variables add an expression like this.. @[User::Email] ( if you click the ... build button on the expression line in properties, it will help you do this )

    you can populate the variables a couple of different ways,,

    1, you can use a configuration.. thats under the ssis menu and then configurations.. or you can right click the screen on the control flow tape and you'll see it.. this will use either an environmental variable, or an xml file that you save locally, or a sql database table for storage of you config database.. I would roughly suggest the xml file version if you don't have a preference.

    there are some other options where you can pass a variable to a sql job that runs the package.. here's one.. if you're wanting to execute the package from vb.net for example, here's some code I had used previously..

    Sub Main()

    Dim pkgLocation As String

    Dim pkg As New Package

    Dim app As New Application

    Dim pkgResults As DTSExecResult

    Dim emailtxt As String = ""

    Dim eventListener As New EventListener()

    Dim FileLocation As String = ""

    If Form1.txtbxFileLocation.Text <> "" Then FileLocation = Form1.txtbxFileLocation.Text

    If Form1.txtbxEmailID.Text <> "" Then emailtxt = Form1.txtbxEmailID.Text

    pkgLocation = "C:\Temp\Package.dtsx"

    pkg = app.LoadPackage(pkgLocation, eventListener)

    If FileLocation <> "" Then pkg.Variables("Path").Value = FileLocation

    If emailtxt <> "" Then pkg.Variables("Email").Value = emailtxt

    pkgResults = pkg.Execute(Nothing, Nothing, eventListener, Nothing, Nothing)

    Form1.Label1.Text = pkgResults.ToString()

    Console.WriteLine(pkgResults.ToString())

    Console.Read()

    End Sub

    hopefully some of that will help.. try to provide more details in your question if you need more info... like how your trying to go about it.. etc..

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

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