87 if(contacts ==
null)
return;
88 Application app = Application.getApplication();
89 SignedReport sr =
new SignedReport();
90 sr.setCertificateStore(certificateStore);
91 if(
new File(ElephantContext.getRealPath(jasperFile)).exists()) {
92 sr.setSrc(jasperFile);
94 sr.setSrc(defaultFile);
96 sr.setParameters(parameters);
97 sr.setDatasource(dataSource);
99 File attach = File.createTempFile(
"attach_",
"_mail");
100 FileOutputStream fos =
new FileOutputStream(attach);
101 InputStream is = sr.getReport().getStreamData();
103 byte[] bytes =
new byte[1024];
104 while ((read = is.read(bytes)) != -1) {
105 fos.write(bytes, 0, read);
110 StringBuilder sb =
new StringBuilder();
111 for(IContact c : contacts) {
112 String email = c.getConnector(IUser.CONNECTOR_EMAIL);
113 if(Contacts.isValidEmail(email)) {
114 MailPool mp = (MailPool) app.getImplementation(
"IMailPool_" + certificateStore);
115 MailMessage mm =
new MailMessage(
116 (String) mp.getAttributes().get(
"mailhost"),
117 (String) mp.getAttributes().get(
"user"),
118 (String) mp.getAttributes().get(
"password"));
119 mm.addTo(email, c.getName());
120 sb.append(email).append(
": ").append(c.getName()).append(
"\n");
121 mm.setFrom((String) mp.getAttributes().get(
"from"), ElephantContext.getSiteName());
122 mm.setSubject(ElephantContext.getSiteName() +
": " + title);
124 "<p><i>" + I_.get(
"Automatically generated") +
"</i></p>" +
125 "<p><b>" + ElephantContext.getSiteName() +
"</b>: " + I_.get(
"Document") +
"</p>");
126 mm.attach(attach.getAbsolutePath(), ElephantContext.getSiteName() +
" " + I_.get(
"Document"), title +
".pdf");
131 if(sb.length() > 0) {
132 ZkossUtils.showMessage(I_.get(
"Send documents"),
133 I_.get(
"Sent") +
"\n\n" + sb.toString());
135 }
catch (Exception ex) {