locked
Email Task - Sending emails to different users RRS feed

  • Question

  • Hi,

    I am stuck with a problem in SSIS and need your suggestions / help to find the perfect solution.

    Problem:

    1) I have a table and 2 columns are needed for this task.

     - Validation Status

    - Email id

    2) I want to check Validation status column and if the value is 'Failed' I must send a email to the corresponding user using the email id column.

    Can you please guide me how to solve this task.

    The main challenge is face is how to send only one email to the user even though for the particular user many rows are returned with validation failed.

    How to send individual emails to different users for the same table. For example if for two users, Validation Status is 'Failed', I would like to have 2 separate emails for the users and not to have both the users in the 'To' field together.

    Thanks a ton in advance!

    Monday, May 4, 2015 3:06 PM

Answers

  • You can do this way Ganesh. 

    with cte as (
    Select distinct emailid, validationstatus from testtable)
    Select emailid from cte 
    where validationstatus='Failed'

    Do you know how many email id's you are expecting..? roughly..

    Keep the above in a execute SQL task and throw the result in to an object variable type, put the result set to full result set. 

    And then iterate the object variable type through for each lookup task and put email task in the foreach so for every iteration new emailid is sent to email task as TOLine will be variable mapped to object variable type. 

    Let me know if you face any issues. 

    Note: In the foreach task , change the enumerator type to Foreach ADO Enumerator. 


    - please mark correct answers


    • Edited by Murali dhar Monday, May 4, 2015 3:21 PM
    • Proposed as answer by JPangging Tuesday, May 5, 2015 6:54 PM
    • Marked as answer by ganeshsg Thursday, May 7, 2015 9:36 AM
    Monday, May 4, 2015 3:19 PM