#1 2018-01-30 10:36:49

aguiral
Member
Registered: 2017-11-30

Send mail to non RS user people

Hi,

I'm using RS CE (RS3.0.3-6000 (2017-10-25-16-10-52)).

It is possible to send an email to a recipient which us a non RS user ?

Thanks

Alfredo

Offline

#2 2018-01-30 12:16:43

eduardo
Administrator
Registered: 2016-11-01
Website

Re: Send mail to non RS user people

Hi Alfredo,

this is not directly supported. Since you can send sensible data with reportserver, it is better to know what has been sent and to whom it has been sent. Therefore, we only allow this for reportserver users.

Nevertheless, you can use the "sendTo" functionality for doing whatever you want with your report. This includes sending it directly to an email address, to more than one email address, etc.
More information on the "SendTo" functionality: https://reportserver.net/en/guides/scri … s/Send-To/

An example is:

import java.util.HashMap;

import net.datenwerke.rs.core.service.sendto.hooks.SendToTargetProviderHook
import net.datenwerke.rs.core.service.sendto.hooks.adapter.SendToTargetProviderHookAdapter
import net.datenwerke.rs.core.client.sendto.SendToClientConfig
import net.datenwerke.rs.core.service.mail.MailService;
import net.datenwerke.rs.core.service.mail.SimpleAttachement;
import net.datenwerke.rs.core.service.mail.SimpleMail;
import net.datenwerke.rs.core.service.reportmanager.ReportExecutorService;
import net.datenwerke.rs.core.service.reportmanager.ReportService;
import net.datenwerke.rs.core.service.reportmanager.engine.CompiledReport;
import net.datenwerke.rs.core.service.reportmanager.engine.config.ReportExecutionConfig;
import net.datenwerke.rs.core.service.reportmanager.entities.reports.Report;
import net.datenwerke.rs.core.service.reportmanager.exceptions.ReportExecutorException;
import net.datenwerke.rs.core.service.sendto.hooks.SendToTargetProviderHook;
import net.datenwerke.rs.scripting.service.scripting.scriptservices.CallbackRegistry;
import net.datenwerke.scheduler.service.scheduler.entities.AbstractJob;
import java.util.HashMap

def HOOK_NAME = "MY_HOOK_NAME"

reportService = GLOBALS.getInstance(ReportService.class)
reportExec = GLOBALS.getInstance(ReportExecutorService.class)
mailService = GLOBALS.getInstance(MailService.class)

String doSendMail(report, values, execConfig) {
  
  try {
		CompiledReport mainReportCompiled = null;
		
        if (execConfig != null) {
			mainReportCompiled = reportExec.execute(report, "EXCEL", execConfig);
        } else {
            mainReportCompiled = reportExec.execute(report, "EXCEL", ReportExecutionConfig.EMPTY_CONFIG);
        }


		SimpleMail mail = mailService.newSimpleMail();
		mail.setSubject("Testreport von SendMail.java");
		mail.setToRecipients("test@reportserver.net");
		mail.setFrom("from@reportserver.net");

		SimpleAttachement mainReportAttachement = new SimpleAttachement(mainReportCompiled.getReport(),
				mainReportCompiled.getMimeType(), "myfile.xlsx");
		mail.setContent("Test", mainReportAttachement);

		// send mail
		mailService.sendMail(mail);

		return "Send the report via mail. Config " + values;
    
    } catch (ReportExecutorException e) {
			e.printStackTrace();
	}
}


def callback = [
  consumes : { report ->
    def config = new SendToClientConfig();
    config.setTitle("Send via script");
    return config;
  },
  getId : { ->
    return "someUniqueIdA"
  },
  sendTo : { report, values, execConfig ->
  	return this.doSendMail(report, values, execConfig);
  },
  
  scheduledSendTo: { compiledReport, report,
			format, values,
			execConfig ->
	return this.doSendMail(report, values, execConfig);
  }

] as SendToTargetProviderHookAdapter

GLOBALS.services.callbackRegistry.attachHook(HOOK_NAME, SendToTargetProviderHook.class, callback)

Regards,
Eduardo

Offline

#3 2018-01-30 15:22:58

aguiral
Member
Registered: 2017-11-30

Re: Send mail to non RS user people

Thank you very much Eduardo.

Offline

#4 2018-05-10 08:49:05

jbaptista
Member
Registered: 2018-05-10

Re: Send mail to non RS user people

Hi,

I'm testing Report Server (Version: RS3.0.3-6002 (2017-12-09-12-26-19) in a Windows Environment) and I need some guidance to implement this script.

Can you help?

many thanks,

Jorge

Offline

#5 2018-05-10 10:13:11

jbaptista
Member
Registered: 2018-05-10

Re: Send mail to non RS user people

I was able to create the script but when i try to sent to a custom email i get the following error:

Error message: groovy.lang.MissingMethodException: No signature of method: Script4$_run_closure3.doCall() is applicable for argument types: (net.datenwerke.rs.base.service.reportengines.table.output.object.CompiledHTMLTableReport, net.datenwerke.rs.base.service.reportengines.table.entities.TableReportVariant, java.lang.String, java.util.HashMap, [Lnet.datenwerke.rs.core.service.reportmanager.engine.config.ReportExecutionConfig;) values: [net.datenwerke.rs.base.service.reportengines.table.output.object.CompiledHTMLTableReport@12a32a3, ...] Possible solutions: findAll(), doCall(java.lang.Object, java.lang.Object, java.lang.Object), findAll()
Recipient: Admin Admin <jbaptista@eap.pt>

Error-Details: net.datenwerke.scheduler.service.scheduler.exceptions.ActionExecutionException: groovy.lang.MissingMethodException: No signature of method: Script4$_run_closure3.doCall() is applicable for argument types: (net.datenwerke.rs.base.service.reportengines.table.output.object.CompiledHTMLTableReport, net.datenwerke.rs.base.service.reportengines.table.entities.TableReportVariant, java.lang.String, java.util.HashMap, [Lnet.datenwerke.rs.core.service.reportmanager.engine.config.ReportExecutionConfig;) values: [net.datenwerke.rs.base.service.reportengines.table.output.object.CompiledHTMLTableReport@12a32a3, ...] Possible solutions: findAll(), doCall(java.lang.Object, java.lang.Object, java.lang.Object), findAll()
    at net.datenwerke.rs.scheduler.service.scheduler.sendto.SendToReportAction.doExecute(SendToReportAction.java:123)
    at net.datenwerke.scheduler.service.scheduler.entities.AbstractAction.execute(AbstractAction.java:59)
    at net.datenwerke.scheduler.service.scheduler.tasks.SchedulerTask.executeAction(SchedulerTask.java:495)
    at net.datenwerke.scheduler.service.scheduler.tasks.SchedulerTask.executeActions(SchedulerTask.java:385)
    at net.datenwerke.scheduler.service.scheduler.tasks.SchedulerTask.safeCall(SchedulerTask.java:209)
    at net.datenwerke.scheduler.service.scheduler.tasks.SchedulerTask.call(SchedulerTask.java:101)
    at net.datenwerke.scheduler.service.scheduler.tasks.SchedulerTask.call(SchedulerTask.java:1)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source) Caused by: groovy.lang.MissingMethodException: No signature of method: Script4$_run_closure3.doCall() is applicable for argument types: (net.datenwerke.rs.base.service.reportengines.table.output.object.CompiledHTMLTableReport, net.datenwerke.rs.base.service.reportengines.table.entities.TableReportVariant, java.lang.String, java.util.HashMap, [Lnet.datenwerke.rs.core.service.reportmanager.engine.config.ReportExecutionConfig;) values: [net.datenwerke.rs.base.service.reportengines.table.output.object.CompiledHTMLTableReport@12a32a3, ...] Possible solutions: findAll(), doCall(java.lang.Object, java.lang.Object, java.lang.Object), findAll()
    at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:284)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016)
    at groovy.lang.Closure.call(Closure.java:423)
    at SendToTargetProviderHookAdapter1_groovyProxy.sendTo(Unknown Source)
    at net.datenwerke.rs.core.service.sendto.hooks.adapter.SendToTargetProviderHookAdapter.scheduledSendTo(SendToTargetProviderHookAdapter.java:45)
    at net.datenwerke.rs.scheduler.service.scheduler.sendto.SendToReportAction.doExecute(SendToReportAction.java:114)
    ... 10 more

Offline

#6 2018-05-14 09:03:10

eduardo
Administrator
Registered: 2016-11-01
Website

Re: Send mail to non RS user people

Hi jbaptista,

could you please post the complete script with which you are getting this error?

Regards,
Eduardo

Offline

Board footer

Powered by FluxBB