Do you know how to get email list of report subscription?
Updated by Jeoffrey Fischer [SSW] 11 months ago. See history
123
<introEmbed
body={<>
You can get email list in ExtensionSettings, which is an XML column in Subscriptions table in database of reporting services. Subscriptions table has a FK with Catalog table, which contains report name and report path information. Then we can XQuery the ExtensionSettings to get TO and CC fields according to report name and report path.
</>}
/>

See the following example. You need to fill report name and report path parameters(@mReportName and @mReportPath). Then this example will return the email dataset of the report's subscriptions.

Figure: Report parameters

Figure: Transfer parameters to dataset
DECLARE xmlCursor CURSOR FORSELECT ExtensionSettingsFROM SubScriptions, [Catalog]WHERE SubScriptions.Report_OID = [Catalog].ItemID AND[Catalog].Name = @mReportName AND[Catalog].Path = @mReportPathDECLARE @settingsXML AS XMLDECLARE @toEmail AS XML DECLARE @ccEmail AS XMLDECLARE @comment AS XMLCREATE TABLE #subscrpt(toEmail XML, ccEmail XML, Comment XML)OPEN xmlCursor/* Perform the first fetch.*/FETCH NEXT FROM xmlCursor INTO @settingsXML/* Check @@FETCH_STATUS to see if there are any more rows to fetch.*/WHILE @@FETCH_STATUS = 0 BEGINSELECT @toEmail = @settingsXML .query('data(/ParameterValues/ParameterValue [Name = "TO"]/Value)')SELECT @ccEmail = @settingsXML .query('data(/ParameterValues/ParameterValue [Name = "CC"]/Value)')SELECT @comment = @settingsXML .query('data(/ParameterValues/ParameterValue [Name = "Comment"]/Value)')INSERT INTO #subscrpt VALUES (@toEmail,@ccEmail,@comment)/* This is executed as long as the previous fetch succeeds.*/FETCH NEXT FROM xmlCursor INTO @settingsXMLENDSELECT toEmail, ccEmail, Comment FROM #subscrptDROP TABLE #subscrptCLOSE xmlCursorDEALLOCATE xmlCursor
✅ Figure: Good example - Get email list
Categories
Related rules
Need help?
SSW Consulting has over 30 years of experience developing awesome software solutions.