22 |
|
|
23 |
public class AddressReport { |
public class AddressReport { |
24 |
|
|
25 |
class NumEntry { |
static class NumEntry { |
26 |
int open = 0; |
int open = 0; |
27 |
int closed = 0; |
int closed = 0; |
28 |
int modified = 0; |
int modified = 0; |
43 |
this.created += other.created; |
this.created += other.created; |
44 |
} |
} |
45 |
} |
} |
46 |
class WeekEntry { |
static class WeekEntry { |
47 |
NumEntry man = new NumEntry(); |
NumEntry man = new NumEntry(); |
48 |
NumEntry tir = new NumEntry(); |
NumEntry tir = new NumEntry(); |
49 |
NumEntry ons = new NumEntry(); |
NumEntry ons = new NumEntry(); |
99 |
String reportData = getReportData(); |
String reportData = getReportData(); |
100 |
String subject = "Indlæsnings rapport for " + source.getDistributor(); |
String subject = "Indlæsnings rapport for " + source.getDistributor(); |
101 |
|
|
102 |
|
AddressReport.sendMail(subject, reportData); |
|
Properties props = new Properties(); |
|
|
props.put("mail.smtp.host", "10.30.1.28"); |
|
|
//props.put("mail.smtp.host", "192.168.12.10"); |
|
|
|
|
|
try { |
|
|
// create some properties and get the default Session |
|
|
Session session = Session.getDefaultInstance(props, null); |
|
|
session.setDebug(false); |
|
|
|
|
|
MimeMessage msg = new MimeMessage(session); |
|
|
msg.setFrom( new InternetAddress("no-reply@daoas.dk") ); |
|
|
|
|
|
|
|
|
msg.setRecipient(Message.RecipientType.TO, new InternetAddress("thn@daoas.dk") );//TODO: mulighed for at ændre modtager mail |
|
|
msg.setSubject( subject ); |
|
|
msg.setContent(reportData, "text/html; charset=utf-8"); |
|
|
|
|
|
Transport.send(msg); |
|
|
|
|
|
|
|
|
} catch (MessagingException e) { |
|
|
System.out.println("Unable to send report mail " + e.getMessage() ); |
|
|
} |
|
|
|
|
103 |
|
|
104 |
} |
} |
105 |
|
|
106 |
|
public static void sendMail(String subject, String htmlBody) { |
107 |
|
Properties props = new Properties(); |
108 |
|
props.put("mail.smtp.host", "10.30.1.28"); |
109 |
|
//props.put("mail.smtp.host", "192.168.12.10"); |
110 |
|
|
111 |
|
try { |
112 |
|
// create some properties and get the default Session |
113 |
|
Session session = Session.getDefaultInstance(props, null); |
114 |
|
session.setDebug(false); |
115 |
|
|
116 |
|
MimeMessage msg = new MimeMessage(session); |
117 |
|
msg.setFrom( new InternetAddress("no-reply@daoas.dk") ); |
118 |
|
|
119 |
|
|
120 |
|
msg.setRecipient(Message.RecipientType.TO, new InternetAddress("thn@daoas.dk") );//TODO: mulighed for at ændre modtager mail |
121 |
|
msg.setSubject( subject ); |
122 |
|
msg.setContent(htmlBody, "text/html; charset=utf-8"); |
123 |
|
|
124 |
|
Transport.send(msg); |
125 |
|
|
126 |
|
|
127 |
|
} catch (MessagingException e) { |
128 |
|
System.out.println("Unable to send report mail " + e.getMessage() ); |
129 |
|
} |
130 |
|
} |
131 |
|
|
132 |
|
|
133 |
public String getReportData() { |
public String getReportData() { |
134 |
|
|
135 |
WeekEntry total = new WeekEntry(); |
WeekEntry total = new WeekEntry(); |