简体   繁体   中英

SSRS 2017 Open Outlook email with multiple email addresses by clicking on a report field

I'm having trouble getting more than one email address into an Outlook Email. I have set the Action "Go to URL" Text Box Properties field in a report as follows:-

="javascript:void(window.open('mailto:" + First(Fields!SUPP_EMAIL.Value, "SUPP_Email")+"'))"

The Dataset is filtered according to the Parameters in the main table. I've tried several means of getting more than one Email address into the Email window, but each time I only get the first in the list, which sort of makes sense as the Function says First! I picked the javascript suggestion up from another post on MSDN from a user who claimed that with this solution they were able to get all addresses from a filtered Dataset. The idea is that once the report has been filtered, a user can click on the/a field designated with the "Go to URL" expression and an Outlook email window will open with all the email addresses in the filtered list in the To Box. If anyone has any suggestions, I would be most grateful.

Depending on how many email addresses you have you might hit a limit. See this answer for more details on that....

Emailing to multiple recipients with html Mailto: not working

However, assuming your dataset is quite small you could do this....

Create a new parameter (eg pEmail ) and make it multi-value. We will hide this parameter later...

Next, the both the Available Values and Default Value for the parameter to your main dataset and use the SUPP_EMAIL field as the value.

On your URL expression use the following

="javascript:void(window.open('mailto:" 
  + JOIN(Parameters!pEmail.Value, ";")
  + "'))"

Once it working, you can set the parameter to hidden.

I've used ; as the delimiter as you said it was for outlook, Be aware that Outlook is almost unique in that respect and most mail clients use a comma not a semi-colon.

Having said all that, this would be easier to do in SQL and build a single row result set containing the URL built ready for use in your report.

You could concatenate the values in the source of the report.

Example SQL:

WITH
la_service_provider_service
AS
(
   SELECT tbl.* FROM (VALUES
    ( 1, '1@gmail.com')
   , ( 1, '2@gmail.com')
   , ( 1, '3@gmail.com')
   , ( 2, '4@gmail.com')
   , ( 2, '5@gmail.com')
   , ( 2, '6@gmail.com')
   , ( 2, '7@gmail.com')
   ) tbl ([LA_SERVICE_PROVIDER_ID], [PROVIDER_EMAIL]) 
)
SELECT 
    [lasps].[LA_SERVICE_PROVIDER_ID]
   , [lasps].[PROVIDER_EMAIL]
   , [ALL_PROVIDER_EMAILS] = 
     STUFF( (SELECT '; '+ [PROVIDER_EMAIL] 
           FROM [la_service_provider_service] AS [lasps2]
           WHERE [lasps2].[LA_SERVICE_PROVIDER_ID] = [lasps].[LA_SERVICE_PROVIDER_ID]
           FOR XML PATH(''), TYPE).value('.', 'NVARCHAR(2000)')
        ,1,2,'')
FROM 
   [la_service_provider_service] AS [lasps];

Results:

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM