Jetzt hab ich mit dem Debug-Modus auch hingekriegt!
Das erste Problem lag darin, dass er das Address[] für cc und bcc nicht erstellt hat, weil new InternetAddress(""); eine Exception wirft.
Das habe ich nun wie folgt geregelt:
Dadurch habe ich ja automatisch null im Array stehen.
In welcher Form muss ich nun die Abfrage
umändern, damit keine NPE mehr kommt?
(if (!cc.equals(null)) funktioniert auch nicht)
Das erste Problem lag darin, dass er das Address[] für cc und bcc nicht erstellt hat, weil new InternetAddress(""); eine Exception wirft.
Das habe ich nun wie folgt geregelt:
Code:
String kopie = Client.getKopie();
String [] ccAdress;
Address [] cc;
if (kopie.contains(",")){
ccAdress = Client.getKopie().split(",");
cc = new Address[ccAdress.length];
for (int i=0; i<ccAdress.length; i++){
try {
cc[i] = new InternetAddress(ccAdress[i]);
System.out.println("Kopie: "+ccAdress[i]);
} catch (AddressException e) {
e.printStackTrace();
}
}
}else if (!kopie.equals("")){
cc = new Address[1];
try {
cc[0] = new InternetAddress(kopie);
System.out.println("Kopie: "+cc[0]);
} catch (AddressException e1) {
e1.printStackTrace();
}
}else{
cc = new Address[1];
cc[0] = null;
}
String blindkopie = Client.getBlindkopie();
String [] bccAdress;
Address [] bcc;
if (blindkopie.contains(",")){
bccAdress = Client.getBlindkopie().split(",");
bcc = new Address[bccAdress.length];
for (int i=0; i<bccAdress.length; i++){
try {
bcc[i] = new InternetAddress(bccAdress[i]);
System.out.println("Blindkopie: "+bccAdress[i]);
} catch (AddressException e) {
e.printStackTrace();
}
}
}else if (!blindkopie.equals("")){
bcc = new Address[1];
try {
bcc[0] = new InternetAddress(blindkopie);
System.out.println("Blindkopie: "+bcc[0]);
} catch (AddressException e1) {
e1.printStackTrace();
}
}else{
bcc = new Address[1];
bcc[0] = null;
}
Dadurch habe ich ja automatisch null im Array stehen.
In welcher Form muss ich nun die Abfrage
Code:
if (cc != null)
msg.setRecipients(Message.RecipientType.CC, cc);
(if (!cc.equals(null)) funktioniert auch nicht)