Send Mail Task using Expressions

  • I have build two user defined variables that get the TO and FROM email ids from a SQL Server Table using a SQL Query. Those variables have the data stored.

    TO Variable: EmailTOVariable

    FROM Variabnle: EmailFROMVariable

    When I am trying to use these variables in the Send Mail Task, I was able to successfully go to the Send Mail Task Editor, Expressions Option and then I have these two User Defined Variables as my expressions.

    FromLine - @[User::EmailTOVariable]

    ToLine - @[User::EmailFROMVariable]

    But now when I go to the Mail tab in the same window, I am not able to understand what should I write in From and To there?

    I tried putting these variable names, but it is showing error and I tried few other ways, but none of those is working.

    I would appreciate if anyone of you could help me know this last step in what I am doing. I just want to know what should I put in the From and To line so that I get the data from these variables (that are mentioned in the expressions tab also).

    Thank you.

  • Yes you need to put these variable in Expressions for FromLine and ToLine property. But note that it Send Mail will keep warning you about no receipient etc. Try to delay validation by setting DelayValidation = Trueon the SendTask property window.

    If you are supplying To and From in your expression this will evaluate when you run your package.

    Edit: DelayValidation = true (actually i thought i put true... 🙂 ...)

    HTH

    Mukti

  • Hi,

    Thank you for your reply. I kept the To and From blank and the DelayValidation is already set to false, but I am still getting an error that No recipient in specified and if I mention that variable, then I get an error that "The adress in the From line is malformed. It is either missing the @ symbol or is not valid.

    Do you have any other suggestions that I can try?

  • Hi,

    I found out the problem.

    We need to leave the To and From field blank, but set the DelayValidation to True, not False.

    When I set it to True, then I was able to get the error messages.

    Thank you.

  • I am trying to use Expression Builder to attach a file to an email. I want the file to be the most recent file in a particular folder. Is this possible?

  • A note on the send mail task. Setting delay validation to true gets the job done but it is the wrong approach in this specific case. What you want to do is to use some sort of a dummy email address (bob@bob.bob) or any email address. For the first run through it is correct that there isn't a value there and that is why you are getting the error and why setting delay validation to true works. however, after the package is run the value in the toline will be set to that of the expression. and will continue to work from then on, all things being equal. always resorting to setting delay validation to true will only get you introuble down the line by making it less likely that you will notice the actual error down the line. sadly the toline doesnt get refreshed automatically from the variable but only when the package is executed. hope this helps.

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

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