- Message message = new MimeMessage(mailSession);
-
- message.setFrom(new InternetAddress("erik@brakkee.org"));
- message.setRecipient(Message.RecipientType.TO, new InternetAddress(
- "erik@brakkee.org"));
- message.setSentDate(new Date());
- message.setSubject("KiSS crawler update");
- message.setText(aText);
- Transport.send(message);
+ InternetAddress from = new InternetAddress("erik@brakkee.org");
+
+ HtmlEmail mail = new HtmlEmail();
+ mail.setMailSession(mailSession);
+ try {
+ mail.setFrom("erik@brakkee.org");
+ mail.setTo(Arrays.asList(new InternetAddress[] { from }));
+ mail.setSentDate(new Date());
+ mail.setSubject("KiSS Crawler Update");
+ String html = aExecutor.getXmlReport().asXML();
+ Document document = new XSLT().transform(html.getBytes(), new FileResource(new File("reportToHtml.xsl")));
+ ByteArrayOutputStream xhtml = new ByteArrayOutputStream();
+ XMLSerializer serializer = new XMLSerializer(xhtml, new OutputFormat());
+ serializer.serialize(document);
+ mail.setHtmlMsg(xhtml.toString());
+ mail.setTextMsg(textReport);
+ mail.send();
+ } catch (EmailException e) {
+ throw new RuntimeException(e);
+ } catch (TransformerException e) {
+ throw new RuntimeException(e);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }