SSIS Send Mail task problem

Hi,

I have got the problem connected with Send Mail Task in SSIS.
The general idea was: sending email alert to different email users. I tried to use Foreach Loop task which loops through dataset (where the emails are stored) and assign different email addresses to SSIS package variable.

When I try to use this task inside Foreach Loop task I receive this error message: "Error: 0xC002F304 at Send Mail Task, Send Mail Task: An error occurred with the following error message: "The parameter 'address' cannot be an empty string."

The SSIS package has variable (string) which is binded with ToLine - property of Send Mail task (it was set up in Expressions tab of Send Mail task). This ToLine property should assign different emails during every loop of Foreach Loop task.

But unfortunately is seems to be not true, because Send Mail task does not allow to assign different values to ToLine property while is in Run-Time.

Have you discovered this quite bizzare Send Mail task behaviour before
I appreciate every help and suggestions.

Thanks,Marek



Answer this question

SSIS Send Mail task problem

  • onion

    DelayValidation will only push the error from Design-Time to Run-Time but that does not appear to be the issue (I am assuming this is a Run-Time error).

    You should set a breakpoint on the e-mail task so you can look at the variables. It really looks like a script is not setting the variable correctly.


  • Ken Paulson

    The problem might be with the variables not being populated at run time, you can try setting the DelayValidation to true in the properties window.


  • aryansingh

    Hi Michael,

    Maybe setting DelayValidation property is the correct approach, but it does not work. I changed every task DelayValidation property to True but I still receive error :

    Error: 0xC002F304 at Send Mail Task, Send Mail Task: An error occurred with the following error message: "The parameter 'address' cannot be an empty string.

    Any ideas I think this is BUG!!!!!!!!!!!!!!!!!

    We need help from Microsoft, some guys from this company should test this and take it into consideration regarding hotfixes and further service packs.

    Cheers, Marek


  • mahesh kuhikar

    Hi,

    Any idea how to solve this problem I got stuck with this issue.

    Your help is very much appreciated.

    Marek


  • Rajagopal Ramadugu

    Hi Nobsay,

    I checked your suggestion. It does not work, my variable does not contain expression - it only receives different email addresses (as string - data type) from SQL table (which is sent to object variable in Foreach Loop task). But I changed this property according to your idea.

    Unfortunately it is not working so far.

    It drives me crazy.....

    MarekR


  • zebi

    Hi FredH,

    The scope of the variable covers the IS package scope.

    I have such expression in Send Mail task:

    ToLine - @[User::Script_AssignEmail]

    This variable (Script_AssignEmail) stores different email address data in every loop step. It should pass different information to ToLine property of Send Mail task, but I still receive such error:

    Error: 0xC002F304 at Send Mail Task, Send Mail Task: An error occurred with the following error message: "The parameter 'address' cannot be an empty string.

    Marek


  • OShah

    Can you setup a really simple test package with the failing task You can send it to my hotmail account just use my fred hirschfeld separated by an underscore account there.
  • Florin Sab?u

    What is the scope of the variable that you are assigning the e-mail address Have you added the expression to the e-mail tasks so that it uses the variable

    I am not having any trouble with this at all (except the bug I noted earlier with SmtpServer).


  • vinayakdb

    check if variable property "Evaluate as expression" is true. Maybe the variable is not correctly resolved at runtime. You can check this by debugging the package and setting a breakpoint before the execution of the task.

    Nobsay


  • Juliocesarlenin

    I think setting DelayValidation to true is the correct approach here - usually the task is validated upfront, so any error is caught fast. But if the task properties depend on execution of other tasks, you need to delay validation until this data is available, when the property can be evaluated to expected value.

  • Nung

    I just tried to create a small test package, and it works fine. Here are the steps I've followed:

    1) Create variable MailAddress at package level

    2) Drop ForEach loop, inside it Send Mail Task

    3) Double click the loop shape, select For Each Item enumerator

    4) Add a column and several e-mail addresses as values

    5) Switch to Variable Mapping, map the MailAddress variable to iterator index 0

    6) Close the For Each loop editor

    7) Open Send Mail Task, configure connection manager, fill From, Subject and MessageSource properties,

    8) In expressions map ToLine to @[User::MailAddress]

    9) close Mail Task editor

    10) In property panel set Delay Validation to true

    11) Run the package, verify I've received the e-mails.

    --

    Alternatively, I've tried removing step 5 and instead setting the variable value in a script task inside the same loop, connected to the Send Mail Task with precedence constraint.

    Both versions work fine, I don't see any bug here. Please check that you've followed the steps as suggested, I suspect you've missed something.



  • BrianBrian

    Hi Michael,

    Thank you for valuable help.

    I checked my package yesterday. It turned out that the problem was in Execute SQL task that was preparing DataSet with emails - I used SQL Case statement syntax which (some how) casued Send Mail task failure. When I replaced Case statement in SELECT query with simple column name - my package started working.

    I have to investigate it more deeply so thank you all guys for valuable support.

    May the SSIS force be with you!

    All the best, Marek


  • SSIS Send Mail task problem