/[projects]/dao/DaoAdresseVedligehold/src/main/java/dk/daoas/adressevedligehold/AddressReport.java
ViewVC logotype

Diff of /dao/DaoAdresseVedligehold/src/main/java/dk/daoas/adressevedligehold/AddressReport.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2855 by torben, Mon Jan 25 10:25:22 2016 UTC revision 2856 by torben, Thu Jan 28 10:27:13 2016 UTC
# Line 99  public class AddressReport { Line 99  public class AddressReport {
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);
103                                    
         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() );  
                 }  
                   
                   
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();

Legend:
Removed from v.2855  
changed lines
  Added in v.2856

  ViewVC Help
Powered by ViewVC 1.1.20