Dynamically Set the to Address in SSRS reports Subscription

前端 未结 1 682
花落未央
花落未央 2021-01-20 09:19

I show a list of items with a field Assigned to, which are email addresses. Right now I have set up a subscription with distinct list of assigned to email addresses and sent

1条回答
  •  粉色の甜心
    2021-01-20 09:42

    Sounds like you need to set up a data driven subscription which is available with the enterprise edition of SSRS 2012.

    Create the report with a User parameter that will create your list of items attached to an email addresses.

    When you then create the data driven subscription you get the opportunity to create another SQL statement that can be used for addressees and to get values to pass as parameters to your report.

    If your proc is created something like (yours will probably be a little more complex...)

    CREATE PROC GetAssigned 
              @EmailAddress nvarchar(255)
    As
    
    IF @EmailAddress is Not null
        SELECT EmailAddress,Item1,Item2
        FROM MyTable
        WHERE EmailAddress = @EmailAddress
    ELSE
        SELECT DISTINCT EmailAddress FROM myTable
    

    You can run this proc in both the report and as the data driven subscription to get the list of email addresses to send and as the parameter to the report. (Although you could just add the SELECT DISTINCT query to the box below rather than having it in the proc?)

    To set up the Subscription (Enterprise version, right?)

    enter image description here

    Although, you could just enter the script in the box above.

    SELECT DISTINCT EmailAddress from MyTable
    
    • Then on the next screen when Entering recipients use the value returned by the proc

    enter image description here

    0 讨论(0)
提交回复
热议问题