SSRS EMail Data-Driven Subscriptions.. File Name need to be changed dynamically.

  • We have the option of changing File Name dynamically in "Windows File Share" delivery method in Data-Driven Subscriptions but is it possible in E-Mail delivery method?

  • Yes 🙂

    1 create manualy subscription and run it

    2 create job whit command eg:

    -- This procedure get data from table [name and email adres] then update subscription and run subscription, wait 60 secends and get next value from table

    BEGIN

    DECLARE @wysylka varchar(max)

    DECLARE @oddzial varchar(200)

    declare @sql nvarchar(max)

    declare @email nvarchar(500)

    DECLARE wysylka_crs cursor for SELECT [Branch],[Adres_email]

    FROM [RPT].[Emails]

    OPEN wysylka_crs

    Set @oddzial = ' '

    WHILE( @@FETCH_STATUS = 0)

    begin

    if @oddzial <>' '

    begin

    UPDATE REPORTSERVER.DBO.SUBSCRIPTIONS

    SET ExtensionSettings = '<ParameterValues><ParameterValue><Name>TO</Name><Value>'+@email+'</Value></ParameterValue><ParameterValue><Name>IncludeReport</Name><Value>True</Value></ParameterValue><ParameterValue><Name>RenderFormat</Name><Value>MHTML</Value></ParameterValue><ParameterValue><Name>Subject</Name><Value>@ReportName dla oddzialu: '+@oddzial+' wygenerowany: @ExecutionTime </Value></ParameterValue><ParameterValue><Name>IncludeLink</Name><Value>False</Value></ParameterValue><ParameterValue><Name>Priority</Name><Value>NORMAL</Value></ParameterValue></ParameterValues>'

    WHERE SUBSCRIPTIONID = '8597C181-AE56-4ED7-B6E3-E9939B858C6E'

    EXEC ReportServer.dbo.AddEvent @EventType='TimedSubscription', @EventData= '8597C181-AE56-4ED7-B6E3-E9939B858C6E'

    WAITFOR DELAY '00:01:00'

    end

    FETCH NEXT FROM wysylka_crs INTO @oddzial,@email

    end

    CLOSE wysylka_crs

    DEALLOCATE wysylka_crs

    END

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

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