implemented Exception handling in EMailSender
This commit is contained in:
parent
fbf1700c34
commit
fd184e1248
|
@ -9,16 +9,10 @@ import java.io.IOException;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
|
||||||
public class BackgroundTasks extends TimerTask {
|
public class BackgroundTasks extends TimerTask {
|
||||||
private final TaskList taskList;
|
|
||||||
private final Garden garden;
|
|
||||||
private final PlantList plantList;
|
|
||||||
private final Notifier notifier;
|
private final Notifier notifier;
|
||||||
//TODO uncomment: privat final WeatherGardenTaskPlaner weatherGardenTaskPlaner;
|
//TODO uncomment: privat final WeatherGardenTaskPlaner weatherGardenTaskPlaner;
|
||||||
|
|
||||||
public BackgroundTasks(TaskList taskList, Garden garden, PlantList plantList) {
|
public BackgroundTasks(TaskList taskList, Garden garden, PlantList plantList) {
|
||||||
this.taskList = taskList;
|
|
||||||
this.garden = garden;
|
|
||||||
this.plantList = plantList;
|
|
||||||
notifier = new Notifier(taskList, garden, plantList);
|
notifier = new Notifier(taskList, garden, plantList);
|
||||||
//TODO uncomment: weatherGardenTaskPlaner = new WeatherGardenTaskPlaner(taskList);
|
//TODO uncomment: weatherGardenTaskPlaner = new WeatherGardenTaskPlaner(taskList);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,7 @@ package ch.zhaw.gartenverwaltung.backgroundtasks.email;
|
||||||
|
|
||||||
import ch.zhaw.gartenverwaltung.Settings;
|
import ch.zhaw.gartenverwaltung.Settings;
|
||||||
|
|
||||||
import javax.mail.Address;
|
import javax.mail.*;
|
||||||
import javax.mail.Message;
|
|
||||||
import javax.mail.MessagingException;
|
|
||||||
import javax.mail.Transport;
|
|
||||||
import javax.mail.internet.InternetAddress;
|
import javax.mail.internet.InternetAddress;
|
||||||
import javax.mail.internet.MimeMessage;
|
import javax.mail.internet.MimeMessage;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -33,8 +30,12 @@ public class EMailSender {
|
||||||
message.setText(text);
|
message.setText(text);
|
||||||
message.setSentDate(new Date());
|
message.setSentDate(new Date());
|
||||||
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(recipients, false));
|
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(recipients, false));
|
||||||
System.out.println("Message is ready: ");
|
try{
|
||||||
Transport.send(message);
|
Transport.send(message);
|
||||||
|
} catch (MessagingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
// TODO logger
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printMail(String receiver, String subject, String text){
|
private void printMail(String receiver, String subject, String text){
|
||||||
|
|
Loading…
Reference in New Issue